Get our FREE VBA eBook of the 30 most useful Excel VBA macros.

Automate Excel so that you can save time and stop doing the jobs a trained monkey could do.

Claim your free eBook

Highlight specific rows in a table

Highlight specific lines in table

In this post, I would like to pick up the example we looked at last week.  We saw that it is possible to highlight specific values in a bar chart.  This makes it very easy for the reader to see the key information quickly.  In this post, we will consider a similar goal, but for tables.  How can we highlight a specific row in a table to draw attention to it?  We will also add a little bit of interactivity to this example by using a combo box to select the value we wish to highlight.

The source data

We will be using the same source data as before.  However, to keep things simple, we will assume that this data is already sorted (if you want to follow an example with unsorted data then follow the first part of last weeks’ post).

Highlight specific row source data

Creating the combo box

We will be using a combo box to select the row we wish to highlight.  A combo box is a type of input box which lets you select from a list (you’ll recognize it when you see it).  To create a combo box you will need the Developer Ribbon enabled.

Then click Developer -> Insert -> Combo Box (Form Control).

Highlight specific row insert combo box

There is also a combo box in the ActiveX controls section, it is similar to the one we are using, but has a few different options.  For this example, we will stick with the Form Control version.

The mouse will become a + shape.  Click and drag a shape to represent the size and location where the combo box should be.  I have created a combo box as shown below.

Highlight specific row - combo box

Next, right click on the combo box and select Format Control….

Highlight specific row - Format Control

The Format Control window will appear.  There are two boxes to be completed:

  • Input range – select the cells representing the list of companies.
  • Cell link – select the cell to display the selected value.

Highlight specific row Format Control window

Now we can use the combo box to select values.  In the screenshot below I have selected Fox Books, this has a value of 3 as it is the 3rd item in the list.

Highlight specific row - combo box Fox Books

Using INDEX to get the company name

The problem is that we want to match the company name of Fox Books, not the location in the list.  So, in Cell F3 we can use the INDEX function to obtain the company name.

Highlight specific row INDEX function

Cell F3 contains the following formula:


The formula is requesting the 3rd result (Cell E3) from the array of values (Cells A2-A8).  The result is Fox Books.

Highlighting the row

We will now use conditional formatting to highlight the row which matches the value in Cell F3.

Select the cells to be highlighted, click Home -> Conditional Formatting -> New Rules.

Highlight specific row - Conditional Formatting

The New Formatting Rule window will open.  Select the last option in the list Use a formula to determine which cells to format.

Highlight specific row New Formatting Rule

Next, we need to create our formula.   Our formula is:


The formula is written for the cell which is highlighted in the selected range (Cell A2 as shown below) but is applied to the whole range (Cells A2-B8).

Highlight specific row Apply Conditional Formatting

The $ symbols are used in the formula to freeze the cell reference, just like normal in formulas.  Therefore, when Excel gets to Cell A3 it knows the formula should be as follows:


Equally, it will create the formula for Cells A4, A5 etc all the way down to A8.

Click Format, and select the formatting you wish.  I’ve chosen a mid-grey fill, so as not to over-power everything.  Click OK, OK again, then OK one more time.  You should now be back to your worksheet with the selected row highlighted.

Highlight specific row - complete example

We can test the highlighting by changing the value in the combo box – Ta-Dah!  The highlighting now changes as the selection changes.  You just need to format it to look nice and you’ve now got an interactive table, which could be used on a dashboard.

Headshot Round

About the author

Hey, I’m Mark, and I run Excel Off The Grid.

My parents tell me that at the age of 7 I declared I was going to become a qualified accountant. I was either psychic or had no imagination, as that is exactly what happened. However, it wasn't until I was 35 that my journey really began.

In 2015, I started a new job, for which I was regularly working after 10pm. As a result, I rarely saw my children during the week. So, I started searching for the secrets to automating Excel. I discovered that by building a small number of simple tools, I could combine them together in different ways to automate nearly all my regular tasks. This meant I could work less hours (and I got pay raises!). Today, I teach these techniques to other professionals in our training program so they too can spend less time at work (and more time with their children and doing the things they love).

Do you need help adapting this post to your needs?

I'm guessing the examples in this post don't exactly match your situation. We all use Excel differently, so it's impossible to write a post that will meet everybody's needs. By taking the time to understand the techniques and principles in this post (and elsewhere on this site), you should be able to adapt it to your needs.

But, if you're still struggling you should:

  1. Read other blogs, or watch YouTube videos on the same topic. You will benefit much more by discovering your own solutions.
  2. Ask the 'Excel Ninja' in your office. It's amazing what things other people know.
  3. Ask a question in a forum like Mr Excel, or the Microsoft Answers Community. Remember, the people on these forums are generally giving their time for free. So take care to craft your question, make sure it's clear and concise.  List all the things you've tried, and provide screenshots, code segments and example workbooks.
  4. Use Excel Rescue, who are my consultancy partner. They help by providing solutions to smaller Excel problems.

What next?
Don't go yet, there is plenty more to learn on Excel Off The Grid.  Check out the latest posts:

Leave a Reply

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