
Excel - Dynamic (auto expanding) chart using a Defined Name
If you have ever wanted your charts range to update when new values are added then follow the steps below. You need to create a Defined Names that expand for the Category (X) axis lables and also for each series.
1. Choose menu option
Insert>Name>Define...2. Give each a useful name (In this example I have used
ChartAxisX)
3. In the Refers to box type the following formula
(This is assuming the your worksheet is called Sheet1 and your chart data starts in column A)Code:
=OFFSET(Sheet1!$A$2,0,0,COUNTA(Sheet1!$A:$A)-1,1)
You will then need to define a name for each series in your chart by repeating step 1 to 3 using the formula below. (In this example I have used the name
ChartValues1)
Code:
=OFFSET(Sheet1!ChartAxisX,0,1)
The above formula uses the Contents of the
ChartAxisX to determine size and then offsets the range by 1 column. (For each additional series you will need to change the value to 2,3,4,... and so on.)
We then need to create a chart using the new Defined Names.
4. Choose menu option
Insert>Chart...5. Select the required chart type and click
Next6. Click the
Series tab, then Add a series (use the following formulas)
Category (X) axis labels: Code:
=Sheet1!UnitsChartAxisX
Values:Code:
=Sheet1!ChartValues1
7. Click Finish