Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) On Error Resume Next Cells.FormatConditions.Delete iColor = 34 With Target.EntireRow.FormatConditions .Delete .Add xlExpression, , "TRUE" .Item(1).Interior.ColorIndex = iColor End With With Target.EntireColumn.FormatConditions .Delete .Add xlExpression, , "TRUE" .Item(1).Interior.ColorIndex = iColor End WithEnd Sub6.儲存,可以看到,如下效果了,當滑鼠點到那,很明顯就能把行和列這樣區分出來了。
1.實現的效果就是滑鼠點到那,都有一個不同的顏色區分出,滑鼠所在位置的行和列
2.我用的版本是office 2010,開啟excel,新建如下圖。
4.選擇檢視程式碼
5.看到如下介面,插入如下程式碼
Private Sub Worksheet_SelectionChange(ByVal Target As Excel.Range) On Error Resume Next Cells.FormatConditions.Delete iColor = 34 With Target.EntireRow.FormatConditions .Delete .Add xlExpression, , "TRUE" .Item(1).Interior.ColorIndex = iColor End With With Target.EntireColumn.FormatConditions .Delete .Add xlExpression, , "TRUE" .Item(1).Interior.ColorIndex = iColor End WithEnd Sub6.儲存,可以看到,如下效果了,當滑鼠點到那,很明顯就能把行和列這樣區分出來了。