如何让在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 = 6


End With


With Target.EntireColumn.FormatConditions


    .Delete


    .Add xlExpression, , "TRUE"


    .Item(1).Interior.ColorIndex = 6


End With


End Sub

温馨提示:答案为网友推荐,仅供参考