When you create a chart in Excel and the source data changes, you need to update the chart’s data source to make sure it reflects the new data.
In case you work with charts that are frequently updated, it’s better to create a dynamic chart range.
This Tutorial Covers:
What is a Dynamic Chart Range?
A dynamic chart range is a data range that updates automatically when you change the data source.
This dynamic range is then used as the source data in a chart. As the data changes, the dynamic range updates instantly which leads to an update in the chart.
Below is an example of a chart that uses a dynamic chart range.
Note that the chart updates with the new data points for May and June as soon as the data in entered.
How to Create a Dynamic Chart Range in Excel?
There are two ways to create a dynamic chart range in Excel:
- Using Excel Table
- Using Formulas
In most of the cases, using Excel Table is the best way to create dynamic ranges in Excel.
Let’s see how each of these methods work.
Using Excel Table
Using Excel Table is the best way to create dynamic ranges as it updates automatically when a new data point is added to it.
Excel Table feature was introduced in Excel 2007 version of Windows and if you’re versions prior to it, you won’t be able to use it (see the next section on creating dynamic chart range using formulas).
In the example below, you can see that as soon as I add new data, the Excel Table expands to include this data as a part of the table (note that the border and formatting expand to include it in the table).
Now, we need to use this Excel table while creating the charts.
Here are the exact steps to create a dynamic line chart using the Excel table:
- Select the entire Excel table.
- Go to the Insert tab.
- In the Charts Group, select ‘Line with Markers’ chart.
The above steps would insert a line chart which would automatically update when you add more data to the Excel table.
Note that while adding new data automatically updates the chart, deleting data would not completely remove the data points. For example, if you remove 2 data points, the chart will show some empty space on the right. To correct this, drag the blue mark at the bottom right of the Excel table to remove the deleted data points from the table (as shown below).
While I have taken the example of a line chart, you can also create other chart types such as column/bar charts using this technique.
Using Excel Formulas
As I mentioned, using Excel table is the best way to create dynamic chart ranges.
However, if you can’t use Excel table for some reason (possibly if you are using Excel 2003), there is another (slightly complicated) way to create dynamic chart ranges using Excel formulas and named ranges.
Suppose you have the data set as shown below:
To create a dynamic chart range from this data, we need to:
- Create two dynamic named ranges using the OFFSET formula (one each for ‘Values’ and ‘Months’ column). Adding/deleting a data point would automatically update these named ranges.
- Insert a chart that uses the named ranges as a data source.
Let me explain each step in detail now.
Step 1 – Creating Dynamic Named Ranges
Below are the steps to create dynamic named ranges:
- Go to the ‘Formulas’ Tab.
- Click on ‘Name Manager’.
- In the Name Manager dialog box, specify the name as ChartValues and enter the following formula in Refers to part: =OFFSET(Formula!$B$2,,,COUNTIF(Formula!$B$2:$B$100,”<>”))
- Click OK.
- In the Name Manager dialog box, click on New.
- In the Name Manager dialog box, specify the name as ChartMonths and enter the following formula in Refers to part: =OFFSET(Formula!$A$2,,,COUNTIF(Formula!$A$2:$A$100,”<>”))
- Click Ok.
- Click Close.
The above steps have created two named ranges in the Workbook – ChartValue and ChartMonth (these refer to the values and months range in the data set respectively).
If you go and update the value column by adding one more data point, the ChartValue named range would now automatically update to show the additional data point in it.
The magic is done by the OFFSET function here.
In the ‘ChartValue’ named range formula, we have specified B2 as the reference point. OFFSET formula starts there and extends to cover all the filled cells in the column.
The Same logic works in the ChartMonth named range formula as well.
Step 2 – Create a Chart Using these Named Ranges
Now all you need to do is insert a chart that will use the named ranges as the data source.
Here are the steps to insert a chart and use dynamic chart ranges:
- Go to the Insert tab.
- Click on ‘Insert Line or Area Chart’ and insert the ‘Line with markers’ chart. This will insert the chart in the worksheet.
- With the chart selected, go to the Design tab.
- Click on Select Data.
- In the ‘Select Data Source’ dialog box, click on the Add button in ‘Legend Entries (Series)’.
- In the Series value field, enter =Formula!ChartValues (note that you need to specify the worksheet name before the named range for this to work).
- Click OK.
- Click on the Edit button in the ‘Horizontal (Category) Axis Labels’.
- In the ‘Axis Labels’ dialog box, enter =Formula!ChartMonths
- Click Ok.
That’s it! Now your chart is using a dynamic range and will update when you add/delete data points in the chart.
A few important things to know when using named ranges with charts:
- There should not be any blank cells in the chart data. If there is a blank, named range would not refer to the correct dataset (as the total count would lead to it referring to less number of cells).
- You need to follow the naming convention when using the sheet name in chart source. For example, if the sheet name is a single word, such as Formula, then you can use =Formula!ChartValue. But if there is more than one word, such as Formula Chart, then you need to use =’Formula Chart’!ChartValue.
You May Also Like the Following Excel Tutorials: