office交流网--QQ交流群号

Access培训群:792054000         Excel免费交流群群:686050929          Outlook交流群:221378704    

Word交流群:218156588             PPT交流群:324131555

Excel点击选中的行改变颜色

2019-11-18 13:45:00
tmtony8
原创
6312

在Excel表格中,我们为了突出显示选中的记录。有时希望高亮显示点击的行。

在当前工作表的Worksheet_SelectionChange事件添加下面的代码,可在鼠标点击后高亮显示该行数据。

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    On Error Resume Next
    
    Cells.FormatConditions.Delete
    
    With Target.EntireRow.FormatConditions
        
        .Delete
        
        .Add xlExpression, , "TRUE"
        
        .Item(1).Interior.ColorIndex = 6
        
    End With
End Sub



附上颜色代码编号。

    分享