Excel Insider
Excel Pro Tips

How to Highlight Active Row in Excel (3 Useful Methods)

Written by:Shihab ShahriarShihab Shahriar
Last Updated:
Share

Working with large Excel spreadsheets can be visually tiresome. Highlighting the active row can make it easier to track data while navigating through rows. This feature is good during data entry, reviewing datasets, or while presenting data live. In this process, when we click on a cell, the related row automatically gets highlighted with the pre-defined colour.

Key Takeaways
To highlight the active row in Excel, follow these steps:

➤Press Alt + F11 to open the VBA Editor.
➤Insert a new module and paste a VBA code that highlights the active row.
➤Close the editor and run the macro or use Worksheet events for automatic highlighting.

In this article, you will learn how to highlight the active row in Excel using a conditional formatting, VBA-based and a mix of conditional formatting and VBA scripting method.
overview image

1

Using Conditional Formatting and VBA to Highlight Active Row in Excel

We can use Conditional Formatting and VBA to Highlight Active Row in Excel when we want to highlight the currently selected row automatically. This is good when we work with large datasets like task trackers, sales logs, or attendance sheets. This method works without defining the name and complex code.

We have a dataset that contains Candy Store Status. We will highlight the entire row of active cells dynamically using this method.

Steps

➤ Open your Excel Worksheet. We have taken a table containing Candy Store Name in Column A, Gummies Sold in Column B, Revenue  in column C, and Stock Product in Column D.

Using Conditional Formatting and VBA to Highlight Active Row in Excel

➤ Select the whole worksheet by clicking on the top left box.

Using Conditional Formatting and VBA to Highlight Active Row in Excel


➤ Go to the home tab from the Ribbon.

Using Conditional Formatting and VBA to Highlight Active Row in Excel


➤ Click on Conditional Formatting > New Rule.

Using Conditional Formatting and VBA to Highlight Active Row in Excel


➤ Choose: “Use a formula to determine which cells to format”

Using Conditional Formatting and VBA to Highlight Active Row in Excel


➤ In the formula box, paste the following formula, and click on the format.

fx
=row()=cell("row")
Using Conditional Formatting and VBA to Highlight Active Row in Excel


➤ Then, Click to the Fill tab → choose a highlight color (e.g., light yellow). Click OK twice to apply the rule.

Using Conditional Formatting and VBA to Highlight Active Row in Excel

➤ Right-click the sheet tab (e.g.,sheet1 ”) → select View Code.

Using Conditional Formatting and VBA to Highlight Active Row in Excel


➤ An interface like this will be opened.

Using Conditional Formatting and VBA to Highlight Active Row in Excel


➤ Click the dropdown on the code window. Then, select "Worksheet".

Using Conditional Formatting and VBA to Highlight Active Row in Excel


➤ Paste the following VBA code between the first and second line:

VBA Code
Target.Calculate
Using Conditional Formatting and VBA to Highlight Active Row in Excel


➤ Now return to the worksheet and click on various cells throughout the sheet. The entire row of the selected cell will now be highlighted in the color you set. If I click on cell D4, the Row 4 gets highlighted.

Using Conditional Formatting and VBA to Highlight Active Row in Excel

2

Applying VBA Macro to Highlight Active Row in Excel


VBA Code is used to dynamically highlight the row containing the active cell. This technique is good when we work with wide or long datasets. We use this method to apply across any Excel worksheet.

We have a table that relates to the product Name, Category, and Stock of a store. We will  highlight the active row to avoid editing the wrong product using the VBA method.
Steps:

➤ Open your Excel file. We have taken a dataset that contains Product Name in Column A, Category in Column C, and Stock in Column C.

Applying VBA Macro to Highlight Active Row in Excel

➤ Press Alt + F11 , or use Fn + Alt + F11  to open the VBA Editor.

Applying VBA Macro to Highlight Active Row in Excel

➤ In the VBA editor, double click on “ThisWorkbook” in the left-hand Project pane

Applying VBA Macro to Highlight Active Row in Excel

➤ Paste the following code in the “ThisWorkbook” code window. This code listens for selection changes and formats the active row with a light yellow fill (RGB(255, 255, 153).

VBA Code
Private Sub Workbook_SheetSelectionChange(ByVal Sh As Object, ByVal Target As Range)
    Static oldRow As Range
    Application.ScreenUpdating = False
    Cells.FormatConditions.Delete
    Target.EntireRow.FormatConditions.Add Type:=xlExpression, Formula1:="=ROW()=ROW(INDIRECT(""RC"",FALSE))"
    Target.EntireRow.FormatConditions(1).Interior.Color = RGB(255, 255, 153)
    Application.ScreenUpdating = True
End Sub
Applying VBA Macro to Highlight Active Row in Excel

➤ Go to the File tab from the Ribbon.

Applying VBA Macro to Highlight Active Row in Excel

➤ Click on Save as and Select Browser.

Applying VBA Macro to Highlight Active Row in Excel

➤ Now, in the save as type, choose: “Excel Macro-Enabled Workbook” from the dropdown list in. Then, click Save.

Applying VBA Macro to Highlight Active Row in Excel

➤ Close the VBA editor and return to Excel. Test it by clicking on different cells
The active row will highlight automatically as you move between cells. Here, we have selected the B5 cell and the whole Row 5 got highlighted.

Applying VBA Macro to Highlight Active Row in Excel

➤ When you open the file next time, Excel will ask to enable macros - click “Enable Content” to activate this feature.

Applying VBA Macro to Highlight Active Row in Excel
Note:➥Excel Online and Excel for Web do not support VBA, so this method will not work there.
➥You can change the highlight color by modifying the RGB(...) values in the code.
➥This highlight is temporary and resets every time you switch sheets or close the workbook unless re-enabled.

3

Use of Conditional Formatting & VBA to Highlight Active Row in Excel

We use this method when we want to highlight the currently selected row automatically using a mix of conditional formatting and VBA script. This is best when we work with large datasets like task trackers, sales logs, or attendance sheets where following the active row visually is important.

We have a dataset that contains a project task tracker. We will locate the row (task) which is actively editing or reviewing using this method.

Steps:
➤ Open your Excel Worksheet. Here, we have taken a table containing Task ID in Column A, Task Name in Column B, and Assigned Name in Column C.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ Go to the Formulas tab in the ribbon and click on Define Name.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ In the Name box, enter: HighlightActiveRow, in the Refers to box, enter: = and Click OK to save.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ Click the small triangle icon at the top-left corner (above row 1 and left of column A) to select all cells.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ Go to the home tab from the Ribbon.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ Click on Conditional Formatting > New Rule.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ Choose: “Use a formula to determine which cells to format”

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ In the formula box, paste the following formula, and click on the format.

fx
=ROW(A1)=HighlightActiveRow
Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤

Then, Click to the Fill tab → choose a highlight color (e.g., light yellow). Click OK twice to apply the rule.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ Right-click the sheet tab (e.g.,sheet 3 Named as Highlight Active Row in Excel ”) → select View Code.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ An interface like this will be opened.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ Paste the following VBA code:

VBA Code
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    With ThisWorkbook.Names("HighlightActiveRow")
        .Name = "HighlightActiveRow"
        .RefersToR1C1 = "=" & ActiveCell.Row
    End With
End Sub
Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ From the File Tab, Click on Save as and choose Browser.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ Choose format Excel Macro-Enabled Workbook (*.xlsm)

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel


➤ Click on various cells throughout the sheet. The entire row of the selected cell will now be highlighted in the color you set. For example, we have selected the entire B5 cells.

Combining Define Name, Conditional Formatting & VBA to Highlight Active Row in Excel
Note:➥This does not override other formatting rules already applied to cells.
➥The method works per worksheet. Repeat steps for each worksheet where needed.
Ensure macros are enabled when reopening the file or this feature won't function.

Downloadable Resources


Get our practice workbook or necessary files that we have worked with to prepare this article.

Highlight Active Row.zip

Practice Workbook · Excel (.xlsx)

Download File

Frequently Asked Questions

Can I highlight the active row without VBA?


Yes, but it requires helper cells and formulas with conditional formatting. However, it's not truly "dynamic" like the VBA method.

Does this work on Excel for Mac?


Yes, but Mac users must enable macros and use the VBA editor accordingly.

Will it highlight multiple selected rows?


The VBA method focuses on a single active cell. For multiple selections, you'd need a more advanced macro.

Does this work in Google Sheets?


No, this method is exclusive to Microsoft Excel. Google Sheets does not support VBA.


Concluding Words


The best method to highlight the active row in Excel is by using VBA. It allows dynamic row highlighting as you move through your spreadsheet while increasing focus and productivity. Once set up, it updates automatically and works seamlessly during navigation. Conditional Formatting in Excel is best to highlight a specific row when macros are a bit restricted.

Free Weekly Tips

Liked this? Get one practical Excel tip every week.

🔒 100% Free · No spam ever · Unsubscribe anytime with 1-click

Comments

No comments yet — be the first to ask a question.

Comments are moderated before they appear. Your email is never shown.