How to highlight active row and column in Excel
How to highlight active row and column in Excel
How to highlight active row and column in Excel
When viewing a large worksheet for a long time, you may eventually
lose track of where your cursor is and which data you are looking at.
To know exactly where you are at any moment, get Excel to
automatically highlight the active row and column for you! Naturally,
the highlighting should be dynamic and change every time you select
another cell. Essentially, this is what we are aiming to achieve:
First, you clear the background color of all cells on the sheet by
setting the ColorIndex property to 0. And then, you highlight the entire
row and column of the active cell by setting their ColorIndex property
to the index number for the desired color.
https://www.ablebits.com/office-addins-blog/highlight-active-row-column-excel/ 1/8
3/5/24, 12:30 PM How to highlight active row and column in Excel
Application.ScreenUpdating = True
End Sub
https://www.ablebits.com/office-addins-blog/highlight-active-row-column-excel/ 2/8
3/5/24, 12:30 PM How to highlight active row and column in Excel
=CELL("row")=ROW()
=CELL("col")=COLUMN()
All the formulas make use of the CELL function to return the
row/column number of the selected cell.
https://www.ablebits.com/office-addins-blog/highlight-active-row-column-excel/ 3/8
3/5/24, 12:30 PM How to highlight active row and column in Excel
Click the Format button, switch to the Fill tab, and select the color
you like.
Click OK twice to close both dialog windows.
If you feel like you need more detailed instructions, please see How
to create formula-based conditional formatting rule.
For this example, we opted for the OR formula to shade both the
column and row in the same color. That takes less work and is
suitable for most cases.
https://www.ablebits.com/office-addins-blog/highlight-active-row-column-excel/ 4/8
3/5/24, 12:30 PM How to highlight active row and column in Excel
Target.Calculate
End Sub
Advantages: unlike the previous method, this one does not impact the
existing formatting you have applied manually.
Add a new blank sheet to your workbook and name it Helper Sheet.
The only purpose of this sheet is to store two numbers representing
the row and column containing a selected cell, so you can
safely hide the sheet at a later point.
Insert the below VBA in the code window of the worksheet where
you wish to implement highlighting. For the detailed instructions,
please refer to our first example.
Private Sub Worksheet_SelectionChange(ByVal Target As
Range)
Application.ScreenUpdating = False
Application.ScreenUpdating = True
End Sub
The above code places the coordinates of the active row and
column to the sheet named "Helper Sheet". If you named your
https://www.ablebits.com/office-addins-blog/highlight-active-row-column-excel/ 5/8
3/5/24, 12:30 PM How to highlight active row and column in Excel
And now, let's cover the three main use cases in detail.
=ROW()='Helper Sheet'!$A$2
As the result, the user can clearly see which row is currently selected:
https://www.ablebits.com/office-addins-blog/highlight-active-row-column-excel/ 6/8
3/5/24, 12:30 PM How to highlight active row and column in Excel
=COLUMN()='Helper Sheet'!$B$2
https://www.ablebits.com/office-addins-blog/highlight-active-row-column-excel/ 7/8
3/5/24, 12:30 PM How to highlight active row and column in Excel
The relevant data is immediately brought into focus, so you can avoid
misreading it.
https://www.ablebits.com/office-addins-blog/highlight-active-row-column-excel/ 8/8