how to highlight row & column in Excel
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
精彩评论