+ Reply to Thread
Results 1 to 4 of 4

VBA Chart Multiple Series

Hybrid View

  1. #1
    Registered User
    Join Date
    03-29-2017
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    60

    VBA Chart Multiple Series

    Can someone please look at the attached workbook and give me some direction?

    There are 3 series I want to plot using VBA code on the same chart. Each series is under"One" "tWo" and "three" on the attached sheet.

    The first series needs to be a straightline plot, the second and third series need to be points (not lines) overlayed on the first line plot. I've tried this for three hours now and keep getting errors. Can someone give it a shot and tell me how to proceed?

    Thank you!


    HTML Code: 
    Attached Files Attached Files
    Last edited by billyjo182; 04-18-2017 at 09:57 AM.

  2. #2
    Forum Expert
    Join Date
    06-09-2010
    Location
    Australia
    MS-Off Ver
    Excel 2013
    Posts
    1,714

    Re: VBA Chart Multiple Series

    Hi
    combining a conventional line and scatter series in the same chart can be problematic as the conventional line series will not be able to have different x values to the other series unless it is on a different x axis. However, if you are happy for your first series to be in xy format but appearing as a line (ie with a line and no markers) then this macro should create a chart in that format:

    Sub CreateChart()
    Dim NewS
    
    ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Select
    ActiveChart.SetSourceData Source:=Range("Sheet1!$A$1:$B$24")
    
    Set NewS = ActiveChart.SeriesCollection.NewSeries
    With NewS
        .Values = Range("$d$2:$d$7")
        .XValues = Range("c$2:$c$7")
        .Name = Range("$d$1")
    End With
    
    Set NewS = ActiveChart.SeriesCollection.NewSeries
    With NewS
        .Values = Range("$f$2:$f$7")
        .XValues = Range("e$2:$e$7")
        .Name = Range("$f$1")
    End With
    
    With ActiveChart.SeriesCollection(1)
        .Format.Line.Visible = msoTrue
        .MarkerStyle = xlNone
    End With
    
    End Sub
    Last edited by NickyC; 04-12-2017 at 09:59 PM. Reason: corrrect code

  3. #3
    Registered User
    Join Date
    03-29-2017
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    60

    Re: VBA Chart Multiple Series

    Is it possible to have 3 line series, and have the second and third series with only markers?

  4. #4
    Registered User
    Join Date
    03-29-2017
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    60

    Re: VBA Chart Multiple Series

    Solved, I used your code plus some additions and edits.

    HTML Code: 
    Last edited by billyjo182; 04-18-2017 at 09:58 AM.

+ 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: 2
    Last Post: 02-19-2017, 07:52 PM
  2. Replies: 1
    Last Post: 06-18-2015, 02:01 PM
  3. River Cross Section Chart - Area Chart Multiple series
    By ppdominic in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-15-2014, 06:01 AM
  4. Replies: 2
    Last Post: 03-05-2013, 03:07 PM
  5. Chart front-to-back series display if series are different chart types
    By Exconomist in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 10-06-2012, 06:49 AM
  6. Multiple Series on one chart
    By Viva_Terlingua in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-29-2011, 04:43 AM
  7. [SOLVED] Chart with multiple series
    By officehub in forum Excel Charting & Pivots
    Replies: 1
    Last Post: 03-09-2006, 02:10 PM

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