Someone asked me how to create a chart where there could select a date range, and the chart would update automatically, to show results for those dates. Here’s a quick look at the chart with dynamic date range setup, and there’s a download link at the end.
Chart for Date Range
The person who asked for help wants to print out a chart of daily test results, for any selected period. They had tried the date range chart tutorial on my website: Excel Chart for Date Range, but it wasn’t what they needed.
That chart is based on a set range of 8 cells, which have colour names, and total sales for those colours in the selected date range.
Dynamic Date Range
Instead of a set range for the chart, he needed a dynamic range. For example, if he selected March 1st to March 31st as the date range, there would be 31 days of data, with multiple tests per day. In February, the list would be shorter.
I created a chart sample that did that, way back in 2009. The article showed how to set up the dynamic ranges, and date selector cells, and the chart.
One of the steps was to set up a named Excel table, which makes it easy to create dynamic ranges. Then, the chart series could be based on those dynamic ranges.
Dynamic Range Problem
But, there was a problem with that method, which I mentioned at the end of the article.
Warning: If you select the entire range, the series formula will revert to absolute cell references instead of the named ranges.
And you never know when somebody might forget that warning, and mess up your workbook!
Avoid the Dynamic Range Problem
A few days later, I wrote another article, and uploaded a new version of the dynamic chart sample file.
I advised against using formatted Excel tables, and recommended OFFSET formulas instead. In my tests, the dynamic ranges were never lost with that method.
That version had a formula to calculate start and end dates too, in case they were reversed in the selection drop downs.
New Dynamic Date Range Chart
The revised sample file worked well, but I hadn’t changed the instruction sheet in the workbook. It still mentioned Excel Tables, and the formulas were all based on table ranges.
To fix that problem, I’ve created a new version of the chart with dynamic date range workbook.
The chart data was moved to a separate sheet, and the calculated date section was moved to an Admin sheet. That sheet could be hidden, so nobody messes up the formulas.
Now the chart is on its own sheet, with the date selection drop downs above it. There’s lots of room now, so you could make the chart bigger.
No Formatted Table
The Setup sheet has updated instructions, and it warns you not to format the list as and Excel Table.
The instructions also show the OFFSET formulas, instead of the table references.
Get the Sample File
To get the sample file with the completed chart with dynamic date range, and the instructions, go to the Excel Sample Files page on my Contextures website.
In the Charts section, look for CH0013 – Chart with Dynamic Date Range. The zipped file is in xlsx format, and does not contain any macros.
Excel Chart with Dynamic Date Range