Select a Cell and Highlight Whole Row in Excel

How-to basics · Updated November 23, 2026

Yes, you can make Excel highlight the entire row when you select a cell. The most reliable method is to use Conditional Formatting with a formula based on the active cell, combined with a small VBA macro that recalculates when the selection changes. This article explains the exact steps, the logic behind them, and alternative approaches.

Why Default Excel Doesn’t Do This

Excel does not have a built-in setting that automatically highlights the row (or column) of the currently selected cell. The reason is that Excel’s conditional formatting rules are evaluated based on cell values, not on the selection. However, you can trick Excel into reacting to the selection by using a formula that references the active cell, and then forcing a recalculation whenever you move to a new cell.

The Core Method: Conditional Formatting + VBA

This method works in Excel 2010 through Microsoft 365 on Windows and Mac. The idea is to create a conditional formatting rule that highlights a row if the row number matches the row number of the active cell. The active cell’s row is obtained using the CELL("row") function. But because CELL only updates when the worksheet recalculates, you need a tiny VBA macro to trigger a recalculation on every selection change.

Step-by-Step Instructions

  1. Select the range where you want the highlighting to apply (for example, A1:Z100). If you want it for the entire sheet, click the square at the top-left corner to select all cells.
  2. Go to Home > Conditional Formatting > New Rule.
  3. Choose Use a formula to determine which cells to format.
  4. In the formula box, enter: =ROW()=CELL("row")
  5. Click Format, go to the Fill tab, choose a highlight color, and click OK.
  6. Click OK to close the New Formatting Rule dialog.
  7. Now open the VBA editor by pressing Alt+F11 (on Mac: Option+F11).
  8. In the Project Explorer, double-click the worksheet you are working on (e.g., Sheet1).
  9. Paste the following code into the code window:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    ' Force a recalculation so CELL("row") updates
    Me.Calculate
End Sub

Close the VBA editor and save the workbook as a macro-enabled file (.xlsm). Now when you select any cell, the whole row will highlight. If you want to highlight the column as well, you can add a second conditional formatting rule with the formula =COLUMN()=CELL("col").

How the Formula Works

The CELL("row") function returns the row number of the active cell. The ROW() function, when used in a conditional formatting rule applied to a range, returns the row number of the cell being evaluated. So for each cell in the range, the rule checks: “Is my row number the same as the row number of the active cell?” If yes, the cell gets the format. The VBA macro simply forces Excel to recalculate the CELL function every time you change the selection, because CELL is volatile only under certain conditions.

Common Problems and Fixes

  • Highlight doesn’t update when you click a new cell: This happens if the macro isn’t running. Make sure macros are enabled, and that the code is in the correct worksheet module (not a standard module).
  • Highlight appears on the wrong row: The formula must be entered exactly as =ROW()=CELL("row") with no extra spaces. Also, ensure the “Applies to” range starts at row 1. If you start at row 2, the formula will be off by one.
  • Cell color doesn’t change when you move with arrow keys: The macro should trigger on any selection change, including arrow keys. If it doesn’t, try pressing F9 to recalc manually, or check that the macro is error-free.
  • Works in one sheet but not another: You must add the VBA code to each worksheet where you want the behavior.

Alternative: Using a Helper Column (No VBA)

If you prefer to avoid VBA, you can simulate row highlighting by using a helper cell that you manually change. For example, put the row number you want to highlight in a cell (say M1), then use a conditional formatting formula like =ROW()=$M$1. This won’t automatically follow your selection, but it’s useful if you want to highlight a specific row without moving the selection. To make it follow the selection without VBA, you would need to use the CELL function and manually press F9 after each click, which is impractical.

Comparing to Google Sheets

In Google Sheets, the same effect is much easier because you can use the CELL function and it updates automatically on selection change without any script. In Google Sheets, you would use the same conditional formatting formula =ROW()=CELL("row") and it just works. If you are working in Google Sheets, you don’t need VBA at all.

Performance and Best Practices

Applying this to an entire column (e.g., A:A) can slow down Excel because conditional formatting is evaluated for every cell in the range. It’s better to limit the range to the actual data area, like A1:Z100. Also, the VBA macro runs on every selection change, which can be noticeable on large sheets. To minimize impact, you can disable the macro when not needed, or use a more efficient VBA approach that only recalculates when the row actually changes.

Frequently Asked Questions

Can I highlight the row and column at the same time?

Yes. Create two conditional formatting rules: one with =ROW()=CELL("row") and another with =COLUMN()=CELL("col"). Both will work together with the same VBA macro.

Will this work in Excel for the web?

No. Excel for the web does not support VBA, so the macro approach won’t work. However, you can still use conditional formatting with CELL, but it will only update when you press F9 or when the workbook recalculates, not automatically on selection change.

How do I remove the highlighting?

Go to Home > Conditional Formatting > Manage Rules, select the rule, and click Delete. Also delete the VBA code from the worksheet module to stop the recalculation.

Does the VBA macro affect undo history?

No, the macro only recalculates the sheet; it does not change any cell values, so undo history is not affected. However, you should save a copy of your workbook before running any macro, as macros cannot be undone with Ctrl+Z.

Can I highlight only the used range instead of the whole row?

Yes, you can modify the conditional formatting formula to check if the cell is non-empty, for example: =AND(ROW()=CELL("row"), A1<>"") but this requires adjusting the range accordingly. Simpler is to just apply the rule to the used range.

Is there a way to do this without VBA in Excel?

Not automatically. Without VBA, the CELL function won’t update on selection change. You could use a manual helper cell, but that defeats the purpose. So VBA is the standard solution in Excel.

Related

Try it: the Date Difference Calculator: days, months, years and weekdays between two dates, with the DATEDIF formulas.

More in How-to basics

Sources: Function behaviour and menu paths: Microsoft Support documentation for Excel. Method & sources

Spotted an error in this guide? Let us know.