|
整行高亮(可设定条件,保护原条件格式)
-------------------------------------------------
Dim lastrow As Integer
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If lastrow = 0 Then
Rows("4:65536").Interior.ColorIndex = xlNone
ElseIf lastrow > 3 Then
Rows(lastrow).Interior.ColorIndex = xlNone
End If
If Target.Row > 3 Then Rows(Target.Row).EntireRow.Interior.ColorIndex = 8 'Allen:排除区域
lastrow = Target.Row
End Sub
会改变原条件格式
-------------------------------------------------
Private Sub Worksheet_SelectionChange(ByVal Target As Range) '鼠标选定触发
Cells.Interior.ColorIndex = 0 '整个工作表无色
Target.Interior.ColorIndex = 34 '鼠标选定区域变色
Selection.EntireColumn.Select
End Sub
'整行变色代码:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Rows().Interior.ColorIndex = 0
x = ActiveCell.Row
Rows(x).Interior.ColorIndex = 10
End Sub
整行、整列变色代码:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.Interior.ColorIndex = 0
Target.EntireRow.Interior.ColorIndex = 3
Target.EntireColumn.Interior.ColorIndex = 4
Target.Interior.ColorIndex = 0
End Sub
'整行着色(即选择其他单元格时,上一步操作不变):
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target.EntireRow.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 65535
.TintAndShade = 0
.PatternTintAndShade = 0
End With
End Sub
-------------------------------------------------
-------------------------------------------------
|
|