Excel 聚光灯效果的实现
Excel 高亮显示选中行列:聚光灯效果
- 条件格式设置公式:
=OR(CELL("row")=ROW())
=OR(CELL("col")=COLUMN())
=(CELL("row")=ROW())+(CELL("col")=COLUMN())
- VBA 工作表选择 Worksheet SelectionChange 加入代码
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error Resume Next
If Application.CutCopyMode = xlCopy Or Application.CutCopyMode = xlCut Then Exit Sub
ActiveSheet.Calculate
End Sub
条件格式设置时,范围要设置整个数据区域;
文件保存格式为 .xlsm
- 纯VBA 实现方式:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
With Target
.Parent.Cells.Interior.ColorIndex = xlNone
.EntireRow.Interior.Color = RGB(230, 230, 250)
.EntireColumn.Interior.Color = RGB(250, 235, 215)
End With
End Sub