Automatically Highlight Active Cell Row in Excel

In this tutorial we are going to learn how to automatically highlight the active cell’s row in Excel. This we will do by using the conditional formatting tool and a small line of macro code.

See below image illustration where the active row is getting highlighted automatically.

auto highlight active row

Doing this basically involves three parts.

  1. Setting up Conditional Formatting Rule
  2. Writing VBA Code
  3. Save workbook as Macro Enabled

Setting Up Conditional Formatting Rule for Auto Highlighting Active Cell Row

Let’s start with the process.

Step1. Get the data ready. You can download the sample data from end of this post.

Step2. Select the data range where you want to apply the automatic highlighting.

Step 3. Click on “Home” tab.

Step 4. Click on “Conditional Formatting”.

Step 5. Click on “New Rule”.

conditional formatting rule for auto highlight row in excel

Step 6. In the “New Formatting Rule” dialog box, click on “use a formula to determine which cell to format”.

Step 7. In the Formula bar write =Cell(“Row”)=Row()

Step 8. Click on “Format” button. (this will open “Format Cell” Dialog box.

Step 9. Click On “Fill” tab.

Step 10. Choose the color that you want for highlighting.

Step 11. Click on “Ok” button of both dialog box.

conditional formatting formula for auto highlight active cell row in excel

Now you have finished setting up the conditional formatting rule. The highlight applies to the active row. But when you switch to other cell, this doesn’t update in real time. For this we have to use VBA code to auto update this.

Write the VBA Code

Step 1. Click on “Developer” Tab.

Step 2. Click on “Visual Basics”.

enabling developer tab for auto refresh the active row highlight

Step 3. Visual basic for applications window opens. Then Double click on sheet name (where you have the data for highlight).

Step 4. Click on the Dropdown.

Step 5. Choose “Worksheet”

vba code to update conditional formatting for auto highlight row

Step 6. Write VBA Code at mid “application.screenupdating=true”

Step 7. Close the VBA Editor Window

vba code for auto refresh conditional formatting for auto highlight of row

Done. Now when you select different cells, the selected cell’s row will get highlighted automatically.

Save the workbook as Macro Enabled Workbook

Now to use this auto highlight next time when you open the file, you need to save the workbook as “Macro Enabled File”.

Follow these steps.

Step 1. Click on “File” tab then “Save As”.

save file as macro enabled

Step 2. In the file type choose “Excel Macro Enabled Workbook”

Step 3. Click on “Save” Button by choosing your desired location.

save file as macro enabled

All done. Now You can use your file with the feature of Automatic Highlight of Active Row.

Note: If you want to remove the automatic highlighting, select your whole data > Home Tab > Conditional Formatting > Clear Rules > Clear Rules from the Selected Cells. Click on Visual Basics and delete the code. You can also save the file as normal workbook (no macro enabled), then the code gets auto removed.

Download the workbook file for practice.

download excel workbook for auto highlight active row

2 thoughts on “Automatically Highlight Active Cell Row in Excel”

  1. The sample file does not even work. What’s wrong? I’m using Excel 2021 for Win 10 Pro on my PC.
    Is this only for Office 365 versions of Excel?

Leave a Reply to EnSLearning Cancel Reply

Your email address will not be published. Required fields are marked *

Scroll to Top