求个EXCEL这个聚光灯宏代码

2025-04-08 05:54:08
推荐回答(2个)
回答1:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim Rng As Range
Set Rng = Target.Range("a1")
Cells.Interior.ColorIndex = 0 '清除所有背景色
Rng.EntireColumn.Interior.ColorIndex = 37 '设置当前列颜色
Rng.EntireRow.Interior.ColorIndex = 37 '设置当前行颜色
Rng.Interior.ColorIndex=2'设置当前单元格颜色
End Sub
试一下不确定,自己身边没电脑

回答2:

WAP自带这个功能。EXCEL需要用到VBA。
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 = 15
End With
With Target.EntireColumn.FormatConditions
.Delete
.Add xlExpression, , "TRUE"
.Item(1).Interior.ColorIndex = 15
End With
End Sub