+ Reply to Thread
Results 1 to 14 of 14

Excel 2007 : Hide Empty Cells when Plotting a Graph

  1. #1
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Hide Empty Cells when Plotting a Graph

    I've read a lot of answers to this question, which all suggest using =na() so that the graph doesn't plot any data for the relevant cells, however, despite having #N/A in the relevant cells, even though nothing visable is plotted, the plotted graph data is still pushed to one side and if showing a legend, items still appear for the #N/A entries.

    For example if the first four rows of data contain =na() producing a #N/A in those cells and the next six rows contain actual data, when the graph is plotted, the six plotted entries are pushed to the right because allowance is still being made for the first four rows.

    Is there any way to completely not plot cells containing #N/A (as if they weren't in the data set at all and for the #N/A cells not to appear in the legend?

  2. #2
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Hide Empty Cells when Plotting a Graph

    hi Hangman, is there a sequence you want your data to be seen? if not, 1 way might be to create another table to base your chart on. this table will not have the NA values. you can use formulas to identify non-NA values your current table & the other table will only pick those with numbers. then do a Name Range for them & include in the chart. i've attached an eg for you.

    do upload a file if this doesn't help
    Attached Files Attached Files

    Thanks, if you have clicked on the * and added our rep.

    If you're satisfied with the answer, click Thread Tools above your first post, select "Mark your thread as Solved".

    "Contentment is not the fulfillment of what you want, but the realization of what you already have."


    Tips & Tutorials I Compiled | How to Get Quick & Good Answers

  3. #3
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Hide Empty Cells when Plotting a Graph

    The NA() trick will only remove data markers from a line series. It will also trim the start or end of the line if the start or end of the data has a contiuous range of NA() cells.
    It will not create a gap in a line series.
    It will not remove column gaps from column charts.
    It will not remove series from the legend.

    To remove column gaps and series you need to hide the cells and make sure the Plot visible cells only is enabled. That's located on the Select data dialog.

    To trim start or end columns you can use the named range approach suggested by benishiryo
    Cheers
    Andy
    www.andypope.info

  4. #4
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Empty Cells when Plotting a Graph

    Hi benishiryo,

    Many thanks for your sample. This works perfectly and does exactly what I need it to do, however, having applied the same logic to my spreadsheet, the only thing my version isn't doing is to change the 'Chart data range', which means that not all the data points are being plotted. I've been looking at this for the last few hours and I can't see any difference between your version and mine, but I'm obviously missing something. I've attached my version to see if you can spot any errors.

    You will see, that despite either 'Region' or 'Area' being selected in cell C4, even though the table updates correctly and the COUNT is correct between the two data sets, the graph only ever plots four data points, rather than adjusting to the correct number of data points.

    What am I doing wrong here?
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Empty Cells when Plotting a Graph

    Andy

    Thanks for your input, that is useful to know as I hadn't realised that the na() trick only applied to line series, which accounts for why I was unable to get this to work correctly. Benishiryo's solution, overcomes this problem perfectly and is very neat. Now, if I could only figure out where I'm going wrong. Can you see the error in my formula. I've been staring at it for a few hours now and I still can't spot the error.

    Many thanks

  6. #6
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Hide Empty Cells when Plotting a Graph

    Named ranges will not work as the number of series is changing not the length of a given series.

  7. #7
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Empty Cells when Plotting a Graph

    Hi Andy

    Sorry (for being thick), are you referring to the fact that my version uses two sets of data, i.e. 2010/2011 and 2011/2012 or the fact that one set of data, namely 'Region' has four data points and the second set of data 'Area' has ten data points? I'm not quite sure I follow.

  8. #8
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Empty Cells when Plotting a Graph

    Hi Andy (again),

    I can actually get it to work (sort of), but I get the following error in the 'Select Data Source' dialogue window. 'The data range is too complex to be displayed. If a new range is selected, it will replace all of the series in the series panel'. I'm unsure why excel thinks the data is to complex as it is being taken from a simple table! I'm clearly missing something here, but I'm not quite sure what? I guess it goes back to your comment, however benishiryo's sample works perfectly. What is the fundamental difference between benishiryo's sample and my version - I think this must be what I'm missing?

  9. #9
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Hide Empty Cells when Plotting a Graph

    His example extends the length of a series, Items on the category axis, depending on the number of data points.

    You however have 2 data points, on the category axis, for each series. And you want to change then number of series, Items in the legend.

    Named ranges will not do that.

  10. #10
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Empty Cells when Plotting a Graph

    Is there any work around or a different approach that could be adopted to achieve what I'm trying to do or am I on to a non-starter?

  11. #11
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Empty Cells when Plotting a Graph

    Andy,

    Okay, I understand what you're saying now and I can see how I can get this to work, it just means the data will be dispalyed differently... Many thanks for your help and input.

  12. #12
    Forum Guru benishiryo's Avatar
    Join Date
    03-25-2011
    Location
    Singapore
    MS-Off Ver
    Excel 2013
    Posts
    5,147

    Re: Hide Empty Cells when Plotting a Graph

    so have you figured it out? i guess your data has to be the other way round. it has to be by regions on the x-axis & the series is in pairs of the different years.

  13. #13
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    O365
    Posts
    20,436

    Re: Hide Empty Cells when Plotting a Graph

    vba would be required if want to retain the same category/legend layout.

  14. #14
    Forum Contributor
    Join Date
    06-21-2010
    Location
    -
    MS-Off Ver
    Excel 2010
    Posts
    1,211

    Re: Hide Empty Cells when Plotting a Graph

    benishiryo,

    Yes, I finally figured it out... Andy pointed out the error in my logic, so I'm simply displaying the data the opposite way and your solution works perfectly, so many thanks for taking the time to help. It is greatly appreciated.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1