Dynamic Chart in Excel
Dynamic Chart in Excel
When we are building a financial model in Excel, we often have to create charts for some ratios
for a certain time span. The question is "Do we have to make 20 charts for 20 ratios?". Most
people do. But by using Excel's OFFSET function, we can create only 1 chart - a dynamic one -
to represent those 20 charts. How? Look at the chart below. It can show a chart for Sales 1,
Sales 2, etc. by simply choosing it from a combo-box. The time span can range from year 2001
up to year 2016. By simply choosing the First Year and Last Year via spinners, we can set any
time span we want.
How do we create it? It's easy. This chart is created using the data within the range of B8:R9,
which in turn is taken from the larger data within the range of B2:R6 by using OFFSET function,
a combo-box and 2 spinners. In this example, we only have 4 rows of Sales data. In reality, we
can have as many as 100 rows or more.
In cell B9, type this formula : =OFFSET(B2,$M$13,0). Copy this formula across the range of
C9:R9. M13 is the cell link of the combo-box. We can find the combo-box and spinner within
the Developer ribbon of our Excel 2007 as depicted below. Now we can create the chart using
the range B8:R9 and choose Column chart. By changing Sales listed in the combo box, the chart
will dynamically change as well - but the time span is still static.
In order to make the time span dynamic, we need to use 2 spinners and 2 named formulas
using OFFSET function
Choose cell B13 as the cell link for the first year's spinner and cell E13 as the cell link for the last
year's spinner. Name cell B13 as "First_Year" and cell E13 as "Last_Year".
1. Press Ctrl and F3 to use the Name Manager. Click New and type "Sales2" in the "Name:" box
and type the following formula in the "Refers To:" box and then click OK:
=OFFSET(Chart!$C$9,0,Chart!$B$13-1,1,Chart!$E$13-Chart!$B$13+1)
2. Press Ctrl and F3 to use the Name Manager. Click New and type "Date2" in the "Name:" box
and type the following formula in the "Refers To:" box and then click OK:
=OFFSET(Chart!$C$8,0,Chart!$B$13-1,1,Chart!$E$13-Chart!$B$13+1)
In order to make the chart dynamic, we have to apply these 2 formulas on the chart as follows:
1. Click on the chart and choose Select Data from the menu box.
2. In the Select Data Source dialog box, click Edit under Legend Entries (Series).
3. In the Edit Series dialog box, type ='Dynamic Chart.xlsx'!Sales2 in "Series values:" box.
4. Repeat step 1 above. In the Select Data Source dialog box, click Edit under Horizontal
(Category) Axis Labels and type ='Dynamic Chart.xlsx'!Date2.
Purwadi Nitimidjojo
0821-2211-2211