Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Jun 2015
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    repetitive line graphing strikes again

    I have many columns of X,Y data in an excel document, I want a macro to make line graphs of each pair of columns. I have tried myself but the macro just keeps producing the same graph from the first pair of columns rather than moving onto the next pair. I tried with relative references aon and with it off, no use. It's driving me bonkers. Please help. I've looked on forums to find an answer but they very quickly exceed my understanding and assume knowledge that I lack, I am using the 'record macro' option not the code editing option to make macros so procedurally what do I need to do to make this work? i.e. what sequence of mouse clicks and button pushes do I need o make once I hit 'record macro' ?

    Matt

  2. #2
    WS Lounge VIP
    Join Date
    Mar 2002
    Location
    Newcazzle, UK
    Posts
    2,824
    Thanks
    135
    Thanked 482 Times in 459 Posts
    Hi Mathew

    ..welcome to the Lounge!

    It would be easier to help you if you could attach an example file.

    zeddy

  3. #3
    Gold Lounger Maudibe's Avatar
    Join Date
    Aug 2010
    Location
    Pa, USA
    Posts
    2,635
    Thanks
    115
    Thanked 649 Times in 592 Posts
    Mathew,

    Here is the code you will need to do what you describe. Adjust the ranges indicated in blue to your specific needs.

    HTH,
    Maud

    Matthew.png

    Code:
    Sub CreateChart()
    '--------------------------
    'CREATE NEW SCATTER CHART
        ActiveSheet.Shapes.AddChart.Select
        ActiveChart.ChartType = xlXYScatterLines
    '--------------------------
    'ADD SERIES 1- ADJUST RANGES AS NEEDED
        ActiveChart.SeriesCollection.NewSeries
        ActiveChart.SeriesCollection(1).Name = "=Sheet1!$A$1"
        ActiveChart.SeriesCollection(1).XValues = "=Sheet1!$A$3:$A$11"
        ActiveChart.SeriesCollection(1).Values = "=Sheet1!$B$3:$B$11"
    '--------------------------
    'ADD SERIES 2- ADJUST RANGES AS NEEDED
        ActiveChart.SeriesCollection.NewSeries
        ActiveChart.SeriesCollection(2).Name = "=Sheet1!$E$1"
        ActiveChart.SeriesCollection(2).XValues = "=Sheet1!$E$3:$E$11"
        ActiveChart.SeriesCollection(2).Values = "=Sheet1!$F$3:$F$11"
    '--------------------------
    'REPEAT FOR EACH NEW SERIES
    End Sub
    Attached Files Attached Files

Posting Permissions

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