+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    Registered User
    Join Date
    07-25-2009
    Location
    Singapore
    MS-Off Ver
    Excel 2003
    Posts
    1

    Vba macro to plot multiple charts

    Hi All. I have searched through tonnes of webpages but yet to find a solution to my idea. Can someone here assist me?

    To put it simply, say, I have x-columns of data. With a mouse click of the macro, I can generate x-series graphs out of these x-columns of data. Eg. If I have 10 columns of data, I will have 10 graphs. If I have 20 columns of data, I will have 20 graphs.

    Also, each graph will plot till the last cell (that has value) of the column.

    Thanks.
    Attached Files Attached Files
    Last edited by keile; 07-29-2009 at 12:46 AM.

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

    Re: Vba macro to plot multiple charts

    Code:
    Sub X()
    
        Dim rngData As Range
        Dim rngColumn As Range
        Dim chtTemp As ChartObject
        Dim sngTop As Single
        Dim sngHeight As Single
        
        sngHeight = 150
        For Each rngColumn In Range("A1").CurrentRegion.Columns
            Set rngData = rngColumn.Range("A1", rngColumn.Range("A1").End(xlDown))
            Set chtTemp = ActiveSheet.ChartObjects.Add(1, sngTop, 200, sngHeight)
            With chtTemp.Chart.SeriesCollection.NewSeries
                .Name = rngData.Cells(1, 1)
                .Values = rngData.Offset(1, 0).Resize(rngData.Rows.Count - 1, 1)
            End With
            sngTop = sngTop + sngHeight
        Next
        
    End Sub
    Cheers
    Andy
    www.andypope.info

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