开发者

how to highlight row & column in Excel

开发者 https://www.devze.com 2023-01-23 21:54 出处:网络
How can I use VBA or conditional formatting to highlight the entire curr开发者_运维知识库ent row and column of the current cell? Thank you.Here\'s one way:

How can I use VBA or conditional formatting to highlight the entire curr开发者_运维知识库ent row and column of the current cell? Thank you.


Here's one way:

ActiveSheet.Rows(ActiveCell.Row).Interior.Color = RGB(r, g, b)
ActiveSheet.Columns(ActiveCell.Column).Interior.Color = RGB(r, g, b)

You can fill in r,g & b to achieve the highlighting color you want.


In your sheets worksheets selection change event, you can use something like this:

Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    Const HIGHLIGHT_COLOR As Long = 4

    'remove past colors
    ActiveSheet.Cells.Interior.ColorIndex = xlNone

    With Me
        .Columns(Target.Column).Interior.ColorIndex = HIGHLIGHT_COLOR
        .Rows(Target.Row).Interior.ColorIndex = HIGHLIGHT_COLOR
    End With
End Sub
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号