Skip to content
On this page

这个是高亮单元格所在行的操作

数据验证时 excel只会高亮所匹配的单元格 而不会高亮那一行

vb
Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Dim rng1 As Range, rng2 As Range, ranges As Range

    Cells.Interior.ColorIndex = xlNone '清空所有颜色

    Set rng1 = ActiveCell.EntireRow

    Set rng2 = ActiveCell.EntireColumn

    Set rng3 = Application.Union(rng1, rng2)

    rng3.Interior.ColorIndex = 20

    Range("A1:AK2").Interior.ColorIndex = 1

End Sub