Why make 100 charts when one will do?

Charts are a great way to explore data. Here is some American baseball data showing player salaries over a five year period.

Baseball salaries by team over time

Charting this data with a line chart would allow us to see trends in salaries by team. However, when we use Excel’s default chart, we get something that looks like this:

Excel's default multiline chart

That’s quite a mess. It would be a lot easier if we could create one chart for each row.

The OFFSET function is going to help. In its simplest form the OFFSET function works like this:

OFFSET(anchor, rows from anchor, columns from anchor)

That is, OFFSET will start with the anchor cell, go down a number of rows from that anchor and over a number of columns and return the value it finds.

OFFSET function

We can use the OFFSET function to create cells that pull a single row of data out of the table dynamically. We create a new row atop of our data and create a series of OFFSET functions that all rely on a single cell (the big yellow one) for their row offset. So changing one cell will pull different rows of data into our fixed location.

Creating a dynamic row that doesn't move

Now, chart the data that doesn’t move.

Charting the dynamic row

After fixing the chart, we’d like to make it easy to change the value in the big yellow cell.

We can use Excel Forms to build a lightweight user interface. Bring up the Excel forms toolbar by rightclicking on any toolbar and choosing Forms. Place a scrollbar beside the chart.

Excel Forms

Right clicking on the scrollbar allows you to Format Control. Link the control to the cell that is controlling all the row offsets. Now, moving the scrollbar will update the chart.

Chart with scrollbar Selecting Format Control Formatting the scrollbar control

Now, the scrollbar controls the chart. Here is the baseball spreadsheet for you to play with: Baseball_offset.xls Have fun!

On the way to 100 charts

Note: this post is adapted from a presentation I gave at eMetrics 2007 in San Francisco.

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License. All source code is released under a BSD License unless otherwise specified.

34 comments | Show all comments only the last 5 are shown


October 13, 2009
ray said:

great and simply outstanding!!!


October 22, 2009
Tim said:

This is great!! This is such a time saver. One question, how do you auto scale the axis in case you have a very wide range of data. For example in one graph I need a to scale to 200, in the next one I need to scale to 5000.

Thanks and keep up the great work you're doing.


February 26, 2010
Sean said:

It sounds like an amazing concept, however, whilst using Excel 2003. It seems that the 'Control' tab on the 'Format Control...' window is missing. Would you be able to provide a sample excel document so that I could look at the VB code behind the scroll bar? or provide the code on here?

Many thanks!


February 26, 2010
Sean said:

Oops, I didn't see the sample document mid way down the page!

Many thanks!


June 29, 2010
Yan said:

Love it! Very easy to understand. Thanks!

Your name

Email (optional, will not be shared)

Type the word "juice" (required to confuse the spammers)

Your comment


Add a comment