I am having trouble with a combination graph in excel specifically with the x axis. I have two columns both go to 1000 but currently only have 13 entries the rest will fill in over time.

I have a formula written to generate #N/A so there are no data points beyond the 13 that I currently have but the x axis still shows 1 to 1000 so the graph is unreadable.

How do I get the x axis labels to stop where the data stops rather than continuing out to 1,000?

Chart Example:

  • Are you plotting the data as a Scatter graph? If so, you can just adjust the x minimum and maximum. – Thales Oct 22 '18 at 19:18
  • It's Column and Line combination graph. – Paul Traver Oct 22 '18 at 19:27
  • 1
    is the NA an error code generated by excel, or is it string made by you? – Forward Ed Oct 22 '18 at 19:50
  • I put the NA in the string so the graph would not show data. – Paul Traver Oct 22 '18 at 20:00

one approach to make it dynamic is to use named formula/range/cell. Instead of graphing A3:A1000 as your Series 1 Y values, you could assign A3:A1000 to the named range Series_1_Y. Edit your data for the graph and then edit the series and use the named range instead.

You can define names here:


That would be the basic concept of named range, but you need it to be more advanced and to be dynamic. There are a few way to achieve this. The basic thing you are going to need to do is determine the number of entries to include. Or in other words the number of rows. You can do this with the COUNT, COUNTIF, COUNTA and the like. You can then combine those results for use in something like OFFSET or INDEX.

In terms of using OFFSET or INDEX, offset is a volatile function, which means it recalculates everytime ANYTHING on the spreadsheet changes. INDEX on the other hand will only recalculate when when something that affects it changes. So depending on how frequently the formula gets used or the size of the calculation, INDEX won't bog your system down as much.

Since you do not have example data, I will work with the following layout:


You can count you entries in a variety of ways. two options are as follows:

'note the above only works for string version of NA
'and adjust characters to match your spelling

The formula you will want to use in your "Define Name" formula will be something to the effect of:





Repeat the process for your second series changing the reference column

when working with your graph data you will need to have saved your spreadsheet first as your workbook name needs to be a part of the series name. I saved my work book as Dtest.xlsx and you can see the "Define Name" being used as the series below:




Note that if your workbook contains a space in the name surround the name in single quote/apostrophe as follows:

'Dtest Two.xlsx'

Caveat: you cannot have any other numbers in the column and your numbers will need to be continuous from their starting point.

  • Yes! I was trying for a while go get this to work (dynamic range with the data), but I think this is the best way to go (if a little top-heavy to set up). – BruceWayne Oct 22 '18 at 21:05
  • 1
    @BruceWayne I originally had it written to use AGGREGATE to determine the last row. The formula works fine on it own, works fine as a defined name, but crashes Excel when the defined name is used in a chart. As a result had to settle for the count method – Forward Ed Oct 22 '18 at 21:12

Perhaps the easiest way is to hide the columns (select the #N/A columns -> Right click -> Hide), they will not show on the graph.

  • Thanks that worked but I need a solution that doesn't involve intervention the workbook is being used by a wide range of inexperienced and experienced users. – Paul Traver Oct 22 '18 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.