Highlight the Active Cell’s Row and Column in Excel
Question details
Make the active cell easier to identify by highlighting its row and column.

- Product
- Microsoft Excel
- Device & OS
- not provided
- Scenario
- The user wants a visual guide that follows the active cell as they select cells in a worksheet.
- Observed behavior
- The active cell’s row and column should be highlighted to make its position easier to see.
Open the workbook in desktop Excel and check whether the worksheet contains fill colors you need to keep. The VBA method below removes existing cell fills throughout the worksheet; use Focus Cell instead if it is available and you need to preserve them.
Highlight the active cell’s row and column with VBA
Use a worksheet selection event to highlight the active row and column within the selected cell’s current region.
The current region is the block of cells bounded by blank rows and columns. The highlight follows a single-cell selection, but the code clears the highlight when multiple cells are selected.
This macro removes all existing cell fills on the worksheet each time the selection changes. Do not use it on a sheet where those colors must be preserved.
In desktop Excel, right-click the worksheet tab and select View Code. If the sheet already has a Worksheet_SelectionChange procedure, incorporate the logic into that procedure rather than adding a second one.
Paste this code into the worksheet’s code window: Private Sub Worksheet_SelectionChange(ByVal Target As Range) Cells.Interior.ColorIndex = xlColorIndexNone If Target.Cells.CountLarge > 1 Then Exit Sub Application.ScreenUpdating = False With Target Range(Cells(.Row, .CurrentRegion.Column), Cells(.Row, .CurrentRegion.Column + .CurrentRegion.Columns.Count - 1)).Interior.ColorIndex = 4 Range(Cells(.CurrentRegion.Row, .Column), Cells(.CurrentRegion.Row + .CurrentRegion.Rows.Count - 1, .Column)).Interior.ColorIndex = 4 End With Application.ScreenUpdating = True End Sub
Choose File > Save As and save the workbook as an Excel Macro-Enabled Workbook (.xlsm). Return to the worksheet and select different cells; enable macros if Excel prompts you and you trust the workbook.
In the code window, replace both instances of ColorIndex = 4 with another Excel color index. To apply the effect on another worksheet, add the event code to that worksheet’s module as well.

Use Excel Focus Cell when available
Use Excel’s built-in visual guide instead of a macro if your version includes Focus Cell.
Work with Excel spreadsheets in WPS Office
WPS Office is a free, lightweight alternative with a familiar interface for opening and editing spreadsheets. Its Excel format support helps you move existing files into WPS, although Excel VBA behavior and features may differ.

Frequently Asked Questions
Why did the VBA macro remove my worksheet colors?
The event starts by setting the worksheet cells’ ColorIndex to xlColorIndexNone, which clears existing fills before adding the new highlight. Use View > Focus Cell instead if your Excel version supports it and you need to retain those fills.
Why is only part of the row or column highlighted?
The VBA code uses the selected cell’s CurrentRegion, which is bounded by blank rows and columns. It highlights the row and column only within that region.
Why does the highlight disappear when I select multiple cells?
The event clears the existing fill and then exits when Target.Cells.CountLarge is greater than 1. Select a single cell to show the highlight again.
Why does the macro not run when I select a cell?
Check that the code is in the relevant worksheet’s module, not a standard module. Save the file as .xlsm and enable macros when prompted if you trust the workbook.
Can I change the highlight color?
Yes. In the worksheet code, change both ColorIndex = 4 values to another Excel color index. If you use Focus Cell, check its drop-down on the View tab for color options.




