Author: Oscar Cronquist Article last updated on May 13, 2021

Highlight a column in a stacked column chart top image

This interactive chart allows you to select a country by clicking on a spin button. The chart and table show the selected country.

I have made something very similar in the year 2013, Highlight a column in a stacked column chart but using Visual Basic for Applications (VBA). This article explains how to build and make it work without VBA.

Highlight a column in a stacked column chart no vba2

The animated image above demonstrates a stacked column chart with a highlighted column based on the selected item using a spin button.

The corresponding row in the Excel Table is also highlighted and the selected country is displayed in cell C14.

1. How to insert a spin button (Form Control)

  1. Go to tab "Developer" on the ribbon.
  2. Click the "Insert" controls button, see the image below.
  3. Click "Spin Button" in group "Form Controls".
    spinbutton form control
  4. Click and hold with left mouse button on the worksheet.
  5. Drag with mouse on the worksheet to size the spin button.
  6. Release the left mouse button.

Back to top

2. How to configure spin button

  1. Right-click on spin button
  2. Click "Format Control..."
  3. Go to tab "Control"
    configure spinbutton form control
  4. Change the maximum value, if you have 10 countries use value 10. 20 countries use value 20.
  5. Select a cell to link the spin button to, see the image above.
  6. Click OK button to apply changes.

Back to top

3. How to link a spin button to a cell value?

selected country

Cell C14 shows the selected country, the cell is linked to the spin button using a formula and refreshes every time you click on the spin button.

  1. Double-click with left mouse button on cell C14.
  2. Type this formula:
  3. Press Enter.

The value changes in cell C14 when you click the spin buttons. The spin button is linked to cell D14.

The formula in cell C14 then uses the value in cell D14 to get the country name in column Country in table Table13. The value is shown in cell C14.

Back to top

4. How to apply Conditional Formatting to an Excel table

  1. Select all values in the Excel Table.
  2. Go to tab "Home" on the ribbon.
  3. Click the "Conditional formatting" button.
  4. Click "New Rule...". A dialog box appears on the screen, see the image below.
    Edit formatting rule
  5. Click on "Use a formula to determine which cells to format" to select it.
  6. Type in "Format values where this formula is true:"
  7. Click "Format..." button. Another dialog box appears.
  8. Pick a color.
  9. Click OK button to return to the first dialog box.
  10. Click OK button to dismiss the first dialog box.

This formula


compares the value in cell C14 with each of the values in column Country, Table13. If a value is a match the entire row is highlighted.

Back to top

Explaining Conditional Formatting formula

Step 1 - Create a structured reference

A cell reference pointing to a value in an Excel Table is different than regular cell references.


The first value is the Table name, in this example: Table13

The item in brackets is the column name in the Excel Table, the @ character points to a cell that is on the same row as the CF formula itself.


Step 2 - Workaround for Excel Tables in CF formulas

The INDIRECT function is needed in order to use a structured reference in a Conditional Formatting formula.


Step 3 - Compare values in column "Country" to value in cell C14

The equal sign lets you compare two or more values to a condition.


An expression using logical operators (equal sign is one of them) is called a logical test or logical expression. The return TRUE or FALSE or their equivalent numerical digit TRUE - 1 or FALSE - 0 (zero).

The Conditional Formatting formula highlights the row if the logical expression returns TRUE and nothing happens if it evaluates to FALSE.

Back to top

5. Copy Excel Table and new formulas

  1. Copy table13
  2. Paste it next to table 13 but keep at least one blank column between tables.
    two excel tables
    Click to enlarge)
  3. Delete all values except headers in the new table
  4. Select the first cell (I3) in the new table and type: =IF(Table13[@Country]=$C$14,Table13[@Country],""). You don´t need to copy the formula to cells below, the table takes care of that.
  5. Cell J3: =IF([@Country]<>"",Table13[@[GDP (nominal)]],"")
  6. Cell K3: =IF([@[GDP (nominal)]]<>"",Table13[@[GDP per capita (nominal)]],"")
  7. Cell L3: =IF([@[GDP (nominal)]]<>"",Table13[@Agricultural],"")
  8. Cell M3: =IF([@[GDP per capita (nominal)]]<>"",Table13[@Industrial],"")
  9. Cell N3: =IF([@[GDP per capita (nominal)]]<>"",Table13[@Service],"")

two excel tables2
Click for larger picture)

We are using the second table to populate the second series in a chart. If this doesn't make sense to you, don't worry.

Back to top

6. Insert a column chart

  1. Select table13 data.
  2. Go to tab "Insert".
  3. Click "Column Chart" button.
  4. Click "Stacked Column" button.
    stacked column chart1
  5. Right click on chart and click "Select Data...".
    stacked column chart2
  6. Remove GDP (nominal).
  7. Remove GDP per capita (nominal).
  8. Click OK.

This is what the chart looks like now.

stacked column chart

Back to top

7. Color all stacked columns

  1. Right click on a column
    stacked column chart3
  2. Click "Format Data Series...".
  3. Click "Fill".
  4. Click "Solid Fill".
  5. Pick a color.
  6. Click on the next column series on the chart.
  7. Repeat step 3 to 5 with all remaining column series.

stacked column chart4

Back to top

8. Add new data to chart

  1. Right-click on the chart.
  2. Click "Select Data...".
  3. Click the "Add" button.
  4. Add series "Agriculture", "Industrial" and "Services" from the second table (not table13).

stacked column chart5

Back to top

9. Plot series on the secondary axis

  1. Right-click on one of the new column series.
    stacked column chart6
  2. Click "Format Data Series...".
  3. Click "Plot Series On Secondary Axis".
    stacked column chart7
  4. Go to tab "Layout" on the ribbon.
  5. Select one of the remaining new series (Agriculture, Services and Industrial).
    stacked column chart8
  6. Repeat step 3.
  7. Make sure you have moved Agriculture, Services, and Industrial series to the secondary axis.

stacked column chart9

Back to top

10. Delete secondary y-axis

stacked column chart10

  1. Select secondary y-axis.
  2. Press Delete.

stacked column chart11

Back to top

Back to top