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.

Display the Developer ribbon

Right-click on a blank part of the ribbon and select Customize the Ribbon… from the menuCustomize Ribbon to display Developer Ribbon

From the Excel Options window click Customize Ribbon, enable the Developer option then click OK.
Display Developer Ribbon in Excel Options

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:

=INDEX(A2:A8,E3)

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

Formula Magic with Dynamic Arrays

Of all the features available in Excel dynamic arrays provide the most power for the smallest time investment.  Yet most Excel users do not even know what they are.

Have you ever faced these spreadsheet scenarios?

  • How can I use VLOOKUP to return all the matching items, not just the first?
  • How can I sort my information using a formula, so I don’t have to keep clicking the sort button?
  • How can I quickly create unique lists of items to use with my SUMIFS calculation?
  • How can I stop copying down formulas every time my source data changes.
  • How can I build a PivotTable-like report, but using formulas so I don’t have to click refresh ever again.

Well, I’m here to give you some good news. with dynamic arrays, all these can be achieved easily 🙂

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:

=$A2=$F$3

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:

=$A3=$F$3

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.



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.

Email Address * First Name *

By entering your email address you agree to receive emails from Excel Off The Grid. We’ll respect your privacy and you can unsubscribe at any time.


Don’t forget:

If you’ve found this post useful, or if you have a better approach, then please leave a comment below.

Do you need help adapting this to your needs?

I’m guessing the examples in this post didn’t exactly meet 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 *