+ Reply to Thread
Results 1 to 10 of 10

Removing a legend entry on a chart

  1. #1
    Registered User
    Join Date
    05-19-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Removing a legend entry on a chart

    HI again

    Was hoping someone could help me out again, trying to get numerous charts working from the same data sources.

    In the attachment, i am have set up a Yes No dropdown to show the series i want to display. Only problem is I don't want a series that doesn't appear in the chart to appear in the legend. (series B in the example).

    Can anyone help?

    Thanks
    Attached Files Attached Files
    Last edited by q felt; 05-30-2010 at 07:29 PM.

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

    Re: Removing a legend entry on a chart

    The only way to automatically remove the legend entry is by removing the series.

    If Series B is set to "No" should the gap between A and C be held in the chart?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    05-19-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Removing a legend entry on a chart

    No I want thegap to go as well. Thanks anayway Andy.

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

    Re: Removing a legend entry on a chart

    Making Series dynamic is a pain.

    One way would be to use a pivot table/chart. Although it requires a change of data layout.

    Otherwise VBA code would be needed to add/remove series and adjust range used.
    Attached Files Attached Files

  5. #5
    Registered User
    Join Date
    05-19-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Removing a legend entry on a chart

    I have realised the limitations re. dynamic series.

    The coding is probably a little beyond my expertise, I only really have a basic knowledge of VBA, and what i am working on is obviously a lot more complex than these examples!

    The pivot table is a good solution, unfortunately I am working with far too much data to use it.

    Thanks as always.

  6. #6
    Registered User
    Join Date
    05-20-2010
    Location
    Fresno, CA
    MS-Off Ver
    2003, 2010
    Posts
    58

    Re: Removing a legend entry on a chart

    q felt,

    Having Andy look this over is kind of like getting batting tips from Babe Ruth (forgive the American reference, but I don't know any famous Cricket players)...but I took a modest poke at it and replaced =IF(...,...,"") with =IF(...,...,NA()). It holds the place for the series just fine, and it looks like it wants to do what you want with the legend, but can't quite get there. You'll see what I mean in the attachment.

    Andy, can you figure why the legend behaves differently, depending on which series becomes "invisible"?
    Attached Files Attached Files
    Thanks,
    Ryan



    A word to the wise is infuriating. - Hunter S Thompson

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

    Re: Removing a legend entry on a chart

    Hi Ryan,

    You are correct that the column gaps are held when using #NA, or "". Unfortunately q felt said, 'No I want thegap to go as well.'

    For a column chart #NA and "" act the same, assuming the axis crossing point is zero.

    The only way to get the legend and column gaps to work is to remove the series.
    You can do this via code or via hiding cells.

    If you set the chart data to use range H4:J8 and use event code on the data validation cells B3:D3 then this will work.

    Please Login or Register  to view this content.

  8. #8
    Registered User
    Join Date
    05-19-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Removing a legend entry on a chart

    Thanks guys.

    I was aware i was getting batting advice from Babe Ruth (Don Bradman is the appropiate cricket reference if it ever comes up again) but if Babe is willing to give tips then who am i not to ask.

    I had a suspicsion that this code was the only way around the problem, now i know for sure, so thanks.

  9. #9
    Forum Expert
    Join Date
    08-27-2008
    Location
    England
    MS-Off Ver
    2010
    Posts
    2,561

    Re: Removing a legend entry on a chart

    Depends how 'polished' you need it to look. You can achieve similar by grouping the individual columns for each series (i.e. each column is one group). You can then use the little plus to pop the series in and out by hiding and unhiding the appropriate column(s). In order to stop the columns merging in to one mega group, you would need to separate them by one column each - which you couldn't hide utterly as it defines the width of the button to unhide the adjacent hidden grouped column.

    Just another way - less pretty, but no code.

    HTH
    CC


    If you feel really indebted please consider a donation to charity. My preferred charity is ActionAid but there are plenty of worthy alternatives.

  10. #10
    Registered User
    Join Date
    05-19-2010
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2003
    Posts
    8

    Re: Removing a legend entry on a chart

    Cheers Charlie, call me vain, but it needs to be pretty. Thanks

+ 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