Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
309 views
in Technique[技术] by (71.8m points)

excel - Auto Highlight Active Row and Column

I managed to auto highlight active row and column by simply using copy paste to "view code".

But is there some simple way to make so that colors in other rows and columns cells remain the same as I have used before. Meaning only active area is changing and others are as original. Then worksheet would be more visual, not only boring white/black.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

simple method to highlight row. paste in sheet code

Dim OldColorIndex As Integer
Dim WorkRange As Range

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Not WorkRange Is Nothing Then WorkRange.Interior.ColorIndex = OldColorIndex
OldColorIndex = Target.Interior.ColorIndex
Set WorkRange = Nothing
Set WorkRange = ActiveSheet.Range(Cells(Target.Row, 1), Cells(Target.Row, Cells(1, Columns.Count).End(xlToLeft).Column))
WorkRange.Interior.ColorIndex = 3
End Sub

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...