VBA & Macro Problems

Highlight the Active Cell’s Row and Column in Excel

Khadija KhanKhadija Khan Nov 18, 2026 870 views

Question details

Make the active cell easier to identify by highlighting its row and column.

Highlight the Active Cell’s Row and Column in Excel
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.
Before you start

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.

Solution 1Recommended

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.

1
Open the worksheet module

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.

2
Add the selection event

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

3
Save and test the workbook

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.

4
Adjust the color or add another sheet

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.

Highlight the active cell’s row and column with VBA
Existing fills are removed: The first line of the event clears cell fills across the sheet, including colors that were present before the macro ran. The highlight is limited to the selected cell’s current region, not necessarily the entire worksheet row and column.
Free Microsoft Office alternative

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.

A familiar spreadsheet interface for navigating rows, columns, and cellsCompatibility with Microsoft Excel formats, including XLSX and XLSA free, lightweight office suite for everyday spreadsheet workOpen existing spreadsheets to make the transition from Microsoft Office easier
QA img-9

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.