filmov
tv
Highlight Row and Column of the Selected Cell - 2 Easy Methods

Показать описание
When working on a large list with column headers and row headers, you can improve the legibility of your data by highlighting the row and column of the selected cell, if you click on another cell, a different row and column are highlighted. But if you click outside the list nothing is highlighted.
In this tutorial I show you 2 methods for doing this either with Conditional Formatting or with a simple VBA code. Let me know in a comment which method you prefer.
So, let’s dive in.
Note:
When using the VBA method, the ro color and Column color extends beyond the range of data. I didn't want to deal with this situation to avoid a much more complicated code. If you are interested in solving this issue, then use this code instead replace the words greater than with the greater than symbol:
Private Sub Worksheet_SelectionChange (ByVal Target As Range)
Cells.Interior.Color = xlColorIndexNone
Dim Nabil As Range
Dim singlecell As Range
Set Nabil = Range ("A2:E25")
If Target.Row greater than26 Or Target.Column Greater than 5 Then
Cells.Interior.ColorIndex = xlColorIndexNone
Exit Sub
Else
For Each singlecell In Nabil
If singlecell.Row = ActiveCell.Row Or singlecell.Column = ActiveCell.Column Then
singlecell.Interior.ColorIndex = 6
End If
Next singlecell
End If
End Sub
In this tutorial I show you 2 methods for doing this either with Conditional Formatting or with a simple VBA code. Let me know in a comment which method you prefer.
So, let’s dive in.
Note:
When using the VBA method, the ro color and Column color extends beyond the range of data. I didn't want to deal with this situation to avoid a much more complicated code. If you are interested in solving this issue, then use this code instead replace the words greater than with the greater than symbol:
Private Sub Worksheet_SelectionChange (ByVal Target As Range)
Cells.Interior.Color = xlColorIndexNone
Dim Nabil As Range
Dim singlecell As Range
Set Nabil = Range ("A2:E25")
If Target.Row greater than26 Or Target.Column Greater than 5 Then
Cells.Interior.ColorIndex = xlColorIndexNone
Exit Sub
Else
For Each singlecell In Nabil
If singlecell.Row = ActiveCell.Row Or singlecell.Column = ActiveCell.Column Then
singlecell.Interior.ColorIndex = 6
End If
Next singlecell
End If
End Sub
Комментарии