+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 : VBA XY scatter plot problems

Hybrid View

  1. #1
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2010, 2019
    Posts
    40,689

    Re: VBA XY scatter plot problems

    Welcome to the forum.

    Please take a few minutes to read the forum rules, and then edit your post to add code tags.
    Entia non sunt multiplicanda sine necessitate

  2. #2
    Registered User
    Join Date
    05-29-2009
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    2

    Re: VBA XY scatter plot problems

    I added the above code tags - Is this what you were referring to? Sorry for the mess up.

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

    Re: VBA XY scatter plot problems

    I change the code slightly so it should be easier to adapt for future use.

    Sub Macro3()
    '
    ' Macro3 Macro
    '
        Dim rngXData As Range
        Dim rngYData As Range
    '
        Set rngXData = Range("A2", Cells(Rows.Count, 1).End(xlUp))
        Set rngYData = rngXData.Offset(0, 1)
        
        With ActiveSheet.Shapes.AddChart.Chart
            Do While .SeriesCollection.Count > 0
                ' remove any series added automatically
                .SeriesCollection(1).Delete
            Loop
            With .SeriesCollection.NewSeries
                .Values = rngYData
                .XValues = rngXData
                .Name = "='" & ActiveSheet.Name & "'!" & rngYData.Offset(-1, 0).Cells(1, 1).Address
            End With
            .ChartType = xlXYScatterSmoothNoMarkers
        End With
        
    End Sub
    Cheers
    Andy
    www.andypope.info

+ 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