+ Reply to Thread
Results 1 to 3 of 3

Thread: how to chart multiple sets of data quickly

  1. #1
    Registered User
    Join Date
    10-20-2010
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    46

    how to chart multiple sets of data quickly

    Hi,

    I am using Excel 2007. I have attached a sample spreadsheet to help explain what I'm trying to do.
    example.xlsx
    I have multiple sets of data (I have listed only a few sets on the sample spreadsheet) and I would like to chart these sets of data individually quickly using using a scatter plot with smooth lines and markers. All sets of data share the same X-values C1:I1. The series names are listed in column A. Y-values are listed in columns C - I. Each set of data has 8 series (actually it is 7 but I didn't know how to enter a title for each plot which are in A2, A10, A18, A26 etc. so I added another series with those cells) The Y-values associated with each series are in column C - I of the same row. I have created a plot with the first set of data in the example sheet, but I have hundreds of sets that I need to do the same thing for. Is there a way to quickly do this without having to manually select each set of data and plot it?

    Thanks

  2. #2
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,349

    Re: how to chart multiple sets of data quickly

    This will create and populate the chart objects.
    You may well need to format other elements within the chart.

    Sub MakeCharts()
        
        Dim rngXData As Range
        Dim rngTitle As Range
        Dim rngYData As Range
        Dim rngName As Range
        Dim chtTemp As Chart
        Dim objSeries As Series
        Dim lngIndex As Long
        
        Set rngXData = Range("C1:I1")
        Set rngTitle = Range("A2")
        Set rngName = Range("A3")
        Set rngYData = Range("C3:I3")
        
        Do While Len(rngTitle) > 0
            Set chtTemp = ActiveSheet.Shapes.AddChart.Chart
            With chtTemp
                .ChartType = xlXYScatterSmooth
                ' remove default data
                Do While .SeriesCollection.Count > 0
                    .SeriesCollection(1).Delete
                Loop
                For lngIndex = 1 To 7
                    With .SeriesCollection.NewSeries
                        .XValues = rngXData
                        .Values = rngYData
                        .Name = rngName
                    End With
                    Set rngYData = rngYData.Offset(1)
                    Set rngName = rngName.Offset(1)
                Next
                .HasTitle = True
                .ChartTitle.Text = rngTitle.Value
                With .Parent
                    .Left = rngYData.Left + rngYData.Width + 10
                    .Top = rngTitle.Top
                    .Height = rngYData.Top - rngTitle.Top
                End With
            End With
            Set rngTitle = rngTitle.Offset(8)
            Set rngYData = rngYData.Offset(1)
            Set rngName = rngName.Offset(2)
        Loop
    End Sub
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    10-20-2010
    Location
    Chicago, Illinois
    MS-Off Ver
    Excel 2007
    Posts
    46

    Re: how to chart multiple sets of data quickly

    thanks Andy

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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.2.0