+ Reply to Thread
Results 1 to 2 of 2

change legend of chart with multiple series

  1. #1
    Registered User
    Join Date
    11-20-2017
    Location
    CA
    MS-Off Ver
    2016
    Posts
    26

    change legend of chart with multiple series

    Hello everyone,

    I use VBA create chart with multiple series line, but the legend show me seris1,series2 instead of the meaningful name(Value1,Value2).
    I don't know how to change the legend name.
    source data looks like this:
    Year 1996 1997 1998 1999 2000 2001 2002
    Value1 86738 92277 101698 116344 131771 145170 161150
    Value2 0.034 0.034 0.036 0.0397636 0.043829871 0.046913567 0.050652176

    here is the VBA I used to generate the chart:

    Set RNG1 = Worksheets("data").Range("B3:H")
    Set RNG2 = Worksheets("data").Range("B4:H4")
    Set RNG3 = Worksheets("data").Range("B5:H5")

    With ActiveSheet.Shapes.AddChart.Chart

    .SetSourceData Source:=Union(RNG1, RNG2, RNG3)
    .ChartType = xlColumnClustered
    .SeriesCollection(2).ChartType = xlLine
    .PlotBy = xlRows
    End With


    Please help.

    Thanks a lot!

  2. #2
    Forum Expert JLGWhiz's Avatar
    Join Date
    02-20-2011
    Location
    Florida, USA
    MS-Off Ver
    Windows 10, Excel 2013
    Posts
    2,070

    Re: change legend of chart with multiple series

    I believe this modified snippet will work for you. Substitute the names you want to use for the myName entries.

    Please Login or Register  to view this content.
    Any code provided by me should be tested on a copy or a mock up of your original data before applying it to the original. Some events in VBA cannot be reversed with the undo facility in Excel. If your original post is satisfied, please mark the thread as "Solved". To upload a file, see the banner at top of this page.
    Just when I think I am smart, I learn something new!

+ 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. [SOLVED] Series name in columns - getting them to be the legend on a chart
    By davidx in forum Excel General
    Replies: 1
    Last Post: 09-03-2014, 11:38 AM
  2. need to remove #N/A from chart legend series
    By plabh in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 06-27-2013, 01:35 AM
  3. Set chart series color to match series legend entries font color
    By Equipoise in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-03-2013, 07:33 AM
  4. How do you change the legend from series to an actual value?
    By jackofalltrades in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 06-04-2012, 02:47 AM
  5. [SOLVED] Exclude one data series from scatter chart legend (but not from the chart)
    By JayUSA in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 05-29-2012, 05:24 PM
  6. Series order in a chart legend.
    By Phil in forum Excel Charting & Pivots
    Replies: 3
    Last Post: 09-28-2005, 04:05 PM
  7. How to hide a dummy series in a chart legend?
    By holg3r in forum Excel - New Users/Basics
    Replies: 2
    Last Post: 07-14-2005, 04:04 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