+ Reply to Thread
Results 1 to 4 of 4

VBA to turn off Legends of plots that does not have data points

  1. #1
    Forum Contributor
    Join Date
    10-01-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    136

    VBA to turn off Legends of plots that does not have data points

    I will like to have a VBA code that can read through a chat to highlight the active legend alone. In my spreadsheet I have several plots, but I want only the plots with data points to display on the legend. I have attached an example in this spreadsheet.

    In the attached spreadsheet you can see that the legend for plot3 is still showing even though there are no data points in it. The plots were created manually with the assumption that there will be data points in them.

    So can someone help me out with a VBA code that will read through the chats and hide the legends that does not have data points (in this case it is plot3)? Also can the code be flexible to be able to bring back the legend when plot3 has values?
    Thanks.
    Attached Files Attached Files

  2. #2
    Forum Contributor
    Join Date
    10-01-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: VBA to turn off Legends of plots that does not have data points

    I basically want to know how to hide legend with no data in series.

  3. #3
    Registered User
    Join Date
    06-12-2015
    Location
    Maryland, USA
    MS-Off Ver
    2010
    Posts
    83

    Re: VBA to turn off Legends of plots that does not have data points

    You can do it in a way to hide the name, but the legend icon (i.e. the green marker + line) will still show up. The only to eliminate the icon is to eliminate the series, but that means you will have to add it again once there is valid data.

    The following code will remove the name but not the icon. It will also restore the name if data is available. You can alternatively code a way to add all the series to the graph, on condition that they have valid data but that is somewhat cumbersome to do in a quick forum reply.

    Please Login or Register  to view this content.

  4. #4
    Forum Contributor
    Join Date
    10-01-2013
    Location
    Houston
    MS-Off Ver
    Excel 2010
    Posts
    136

    Re: VBA to turn off Legends of plots that does not have data points

    @JoeFoot...Thanks a lot for the code. I will build more on it.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 4
    Last Post: 07-21-2014, 07:09 AM
  2. Series plots with multiple time points - data in columns
    By Agupt in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 07-02-2014, 12:34 PM
  3. Scatter Plots - how can I join up the points
    By twinkle001 in forum Excel General
    Replies: 1
    Last Post: 06-12-2012, 01:52 PM
  4. Scatter plots - maximum ordinate points
    By Bobb09 in forum Excel General
    Replies: 0
    Last Post: 06-10-2011, 06:48 PM
  5. Excel 2007 : auto chart macro now plots points not lines
    By richardeallen in forum Excel General
    Replies: 1
    Last Post: 08-19-2008, 07:49 AM

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