|
终于在大神的套路中找到正路,必须要收藏备用用的是excel2007 ,想要行列在不改变原有的单元格颜色的条件下,点击某一单元格令行和列叉高亮显示:
代码:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Cells.FormatConditions.Delete
With Target.EntireColumn
.FormatConditions.Add xlExpression, , "=true"
.FormatConditions(1).Interior.ColorIndex = 27
End With
With Target.EntireRow
.FormatConditions.Add xlExpression, , "=true"
.FormatConditions(2).Interior.ColorIndex = 27
End With
End Sub
如果只是想要行高亮显示:
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range)
On Error Resume Next
Cells.FormatConditions.Delete
With Target.EntireRow.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = 28
End With
End Sub
Sub test()
Dim k As Byte
For k = 1 To 56
Cells(k, 1) = k
Cells(k, 2).Interior.ColorIndex = k
Next k
End Sub
最后保存表格格式为97-2003
|
|