You can create a bar chart race in Excel by combining a sorted data table, a dynamic chart, and a simple VBA macro to automate the progression of time. A bar chart race is an animated visualization that shows how rankings change over a specific period, making it ideal for comparing growth, sales, or population trends. Because Excel does not have a native "Race Chart" button, you must set up a system where a single cell controls the time frame, and the chart updates to reflect the top performers for that specific moment.

What You'll Need

  • Microsoft Excel (Desktop version is required for VBA macros).
  • A dataset organized with categories in rows and time increments (days, months, or years) in columns.
  • Basic familiarity with the "Sort" function and the Developer tab.
  • A set of data that contains enough variance to make the ranking shifts visually interesting.

Step-by-Step

  1. Prepare Your Raw Data: Create a sheet named "Data". Place your categories (e.g., Company Names) in Column A. In the subsequent columns (B, C, D, etc.), enter your time intervals as headers (e.g., 2020, 2021, 2022). Fill the cells with the numerical values you want to track. Ensure there are no blank rows or columns within the dataset.
  2. Create the Animation Control Cell: On a new sheet named "Race", pick a cell (for example, Cell A1) to act as your time slider. Enter the starting year or period from your data headers into this cell. This cell will be the "trigger" that tells Excel which column of data to pull for the chart.
  3. Set Up the Dynamic Ranking Table: You need a separate table that only shows the top N items (e.g., Top 10) for the current period selected in Cell A1. To do this, use a combination of the INDEX, MATCH, and LARGE functions. First, use a formula to pull the values for the period specified in A1. For example, use =INDEX(Data!B2:Z100, 0, MATCH(A1, Data!B1:Z1, 0)) to grab the entire column corresponding to the date in A1.
  4. Sort the Dynamic Data: Since a bar chart race requires the bars to move up and down, the data must be sorted from largest to smallest in real-time. In your dynamic table, use the LARGE function to find the 1st largest value, 2nd largest, and so on. Use =LARGE(Range, 1) for the first row, =LARGE(Range, 2) for the second, etc. Then, use an XLOOKUP or INDEX/MATCH to find the name of the category associated with that specific value.
  5. Insert the Bar Chart: Highlight your dynamic Top 10 table (the names and the values). Go to the Insert tab and select a Clustered Bar Chart. Right-click the Y-axis (the category names), select Format Axis, and check the box for "Categories in reverse order". This ensures the highest value is at the top of the chart.
  6. Clean Up the Visuals: Remove the gridlines, legend, and chart title for a cleaner look. Right-click the bars and adjust the Gap Width to make the bars thicker, which looks better during animation. Ensure the X-axis (the values) has a fixed minimum and maximum if you want to avoid the axis jumping around as the numbers grow.
  7. Enable the Developer Tab: To automate the movement, you need VBA. If you don't see the Developer tab, right-click any ribbon tab, select Customize the Ribbon, and check the box for Developer.
  8. Write the Animation Macro: Click the Visual Basic button in the Developer tab. Insert a new Module and paste a script that increments the value in Cell A1. The code should look roughly like this: a loop that starts at your first date, adds one to the cell value, waits for a fraction of a second (using Application.Wait), and repeats until it reaches the final date in your dataset.
  9. Run the Race: Close the VBA editor. Go to the Developer tab, click Macros, select your animation script, and click Run. You will see the value in Cell A1 change automatically, which triggers the dynamic table to re-sort, which in turn causes the bars in the chart to move and swap positions.

Common Mistakes

One of the most frequent errors is failing to fix the X-axis. By default, Excel auto-scales the axis. If your data grows from 10 to 1,000, the axis will constantly shift, making the bars look like they are vibrating rather than sliding. Always set a fixed Maximum value in the Axis Options that is slightly higher than your highest data point.

Another mistake is using a dataset with duplicate values. If two categories have the exact same value, the XLOOKUP or INDEX/MATCH functions may return the same name twice for both the 1st and 2nd place spots. To prevent this, add a tiny, invisible decimal to your raw data (e.g., adding =ROW()/1000000 to the value) to ensure every number is unique.

Users often forget to save the file as an Excel Macro-Enabled Workbook (.xlsm). If you save it as a standard .xlsx file, all your VBA code will be deleted, and the animation will stop working the next time you open the file.

Tips

To make the animation smoother, reduce the wait time in your VBA script. Instead of using a full second, use Now + TimeValue("00:00:01") / 2 to create a half-second interval. This makes the transitions feel less choppy.

Add data labels to the end of the bars. Right-click a bar and select Add Data Labels. This allows the viewer to see the exact numbers as they climb, which adds a layer of professional detail to the visualization.

Use conditional formatting or a specific color palette for your bars. If you have a specific "hero" category you want the audience to track, give that bar a distinct color (like bright blue) while keeping all other bars a neutral grey.

Troubleshooting

If the bars are not moving, first check if Macros are enabled. Go to File > Options > Trust Center > Trust Center Settings > Macro Settings and select "Disable all macros with notification". When you reopen the file, click "Enable Content" in the yellow bar at the top.

If the names in the chart are not updating even though the numbers are, check your lookup formulas. Ensure that the range in your XLOOKUP or INDEX/MATCH is locked using absolute references (dollar signs, e.g., $A$2:$A$100). If the range shifts as the formula is dragged down, it will pull the wrong names.

If the chart is flickering violently, it is likely because the sorting is happening too fast for the graphics engine. Try increasing the wait time in your VBA code by a few milliseconds or disabling "Screen Updating" at the start of the macro and enabling it only at the end of each loop iteration using Application.ScreenUpdating = False and True.

Frequently Asked Questions

Can I do this without VBA?

Not fully. You can create a manual race by changing the date cell yourself, but the "race" effect requires automation, which in Excel is handled by VBA macros.

Will this work on Excel for Web or Mobile?

No. VBA macros are not supported in the web version or mobile apps of Excel. You must use the desktop application for Windows or macOS to run the animation.

How do I handle data with different time intervals?

Ensure your time headers are consistent. If you have some months missing, the macro will skip them or error out. Fill in missing months with the previous month's value to keep the animation fluid.

Can I show more than 10 bars?

Yes, you can expand your dynamic table to 20 or 50 items. However, too many bars make the chart cluttered and harder to read. 5 to 12 is generally the sweet spot for readability.

How do I export the race as a video?

Excel cannot export animations as video files. The best method is to use a screen recording tool (like Windows Game Bar or QuickTime) to record the screen while the macro is running.