How to Create an Excel Chart with a Dynamic Number of Columns
Question details
The user needs to set up a chart that automatically adjusts its horizontal width (number of columns) as new data or headers are added or removed over time.

- Product
- Spreadsheets
- Device & OS
- not provided
- Scenario
- Building a dashboard or automated report where new columns, such as new months or categories, are continuously added and the chart needs to reflect these updates instantly without manual editing.
- Observed behavior
- Instead of manually adjusting the chart data range every time a new column of data is added, the user wants the chart to expand automatically to accommodate the new inputs.
Ensure your dataset is organized continuously without any completely empty columns in between, as blank columns can disrupt the calculation of the dynamic range formula.
Use OFFSET and Named Ranges for Dynamic Chart Columns
Create a dynamic formula using the OFFSET function and assign it to a named range. Use this named range in the chart's series to make it expand automatically.
The OFFSET function can define a dynamic width by counting the number of non-empty cells in a row. By coupling OFFSET with the Name Manager, you can create a reference that expands horizontally as data grows.
Go to the Formulas tab on the ribbon and click 'Name Manager'. Click 'New', name it 'ChartHeaders', and enter an OFFSET formula in the 'Refers to' box (e.g., =OFFSET(Sheet1!$B$1, 0, 0, 1, COUNTA(Sheet1!$1:$1)-1)).
Create another named range (e.g., 'ChartData') for the values. Use a similar OFFSET formula that references the data row but keeps the same dynamic width count: =OFFSET(Sheet1!$B$2, 0, 0, 1, COUNTA(Sheet1!$1:$1)-1).
Select the first few cells of your data and navigate to the Insert tab. Choose your preferred chart type (such as a Column or Line chart) and place it on your worksheet.
Right-click the chart and click 'Select Data'. Edit the Legend Entries (Series) and Horizontal (Category) Axis Labels. Instead of selecting cells, type the sheet name followed by your named ranges (e.g., =Sheet1!ChartData and =Sheet1!ChartHeaders).

Format Data as a Table for Simpler Dynamic Ranges
If you are using modern spreadsheet versions, formatting your data as a Table automatically forces connected charts to expand when new columns are added, avoiding complex formulas.
Create Dynamic Charts Effortlessly in WPS Spreadsheet
WPS Spreadsheet provides a robust Name Manager and full support for advanced array formulas like OFFSET, allowing you to build automated, auto-updating charts with complete accuracy.
- 1. Open WPS Spreadsheet: Launch WPS Office and open your workbook containing the data you wish to chart.
- 2. Access Name Manager: Navigate to the Formulas tab and select Name Manager to create your dynamic OFFSET ranges.
- 3. Insert and Link the Chart: Go to the Insert tab, add your preferred chart, right-click to Select Data, and input your newly created dynamic named ranges.

Frequently Asked Questions
Why does my spreadsheet say 'invalid external reference' when adding named ranges to a chart?
This happens if you type the named range directly without the sheet name or workbook name prefix. Always include the sheet name when referencing named ranges in the Select Data dialog, such as =Sheet1!MyRange.
Can I use the INDEX function instead of OFFSET for dynamic columns?
Yes, INDEX can also define dynamic ranges and is preferred by some users because it is a non-volatile function. This means it doesn't recalculate continuously, potentially improving the calculation speed of large workbooks.
Does formatting as a table work for both dynamic columns and rows?
Yes, formatting a dataset as a Table (using Ctrl+T) makes both columns and rows dynamic. Any chart connected to that table will expand automatically when you type new data adjacent to the right side (columns) or the bottom (rows).
Why is my OFFSET formula returning blank or zero values on the chart?
Ensure your COUNTA function is counting the correct row or column. If there are hidden spaces, formatting, or empty cells within your data range, COUNTA may calculate an incorrect width, causing the OFFSET range to misalign.




