+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Registered User
    Join Date
    08-10-2009
    Location
    Fort Collins, Colorado
    MS-Off Ver
    Excel 2003
    Posts
    29

    adding column clustered chart

    Hi, I'm trying to add a column clustered chart and I'm not sure how to define the names, values and x category labels for my different series. I posted what code I do have but I am just trying to follow the Peltier website. I like how the ranges are easy to define in his method. I will post the link to that below. I think that the Peltier code is intended for a scatter line plot. I obviously need to create a column clustered chart instead. Any help you can give to put me on the right track would be greatly appreciated.

    Thanks

    http://peltiertech.com/Excel/ChartsH...html#VBAcharts

    Code:
    Private Sub CommandButton2_Click()
        Set myChtObj = Worksheets("Individual Jobs").ChartObjects.Add _
            (Left:=12, Width:=370, Top:=2042, Height:=239)
        myChtObj.Chart.ChartType = xlColumnClustered
        With ActiveChart.SeriesCollection.NewSeries
            .Name = Worksheets("Graph Reference").Range("AA4")
            .Values = Worksheets("Graph Reference").Range("some range")
            .XValues = Worksheets("Graph Reference").Range("some range")
        End With
    Last edited by buckfran; 08-13-2009 at 03:06 PM.

  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: adding column clustered chart

    it would help if you post a sample data file or defined the ranges you intend using.

    What does the code currently produce?
    Cheers
    Andy
    www.andypope.info

  3. #3
    Registered User
    Join Date
    08-10-2009
    Location
    Fort Collins, Colorado
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: adding column clustered chart

    It does not currently produce anything. I am using the Peltier framework, but I don't think that it works for a clustered chart. I understand that the .name is the series name, but it is unclear to me what the .Values and .Xvalues are. The current error that I receive is "Object variable or with block variable not set".

    If I were to use the chart creation tool provided with excel, I would have two series.

    The name of series 1 would be in AA4 and the series would have the values in AA13 and AV13.

    The name of series 2 would be in AB4 and the series would have the values in AB13 and AW13.

    Both series would have the same Category (X) Axis labels.

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

    Re: adding column clustered chart

    The error is because you create a chart object on the non active sheet and then rather than using the object reference you created you use the Activechart object. I would guess that Jon's original code did not create the chartobject on a different sheet to the data.

    Code:
        Dim myChtObj As ChartObject
        
        Set myChtObj = Worksheets("Individual Jobs").ChartObjects.Add _
                        (Left:=12, Width:=370, Top:=10, Height:=239)
        myChtObj.Chart.ChartType = xlColumnClustered
        With myChtObj.Chart.SeriesCollection.NewSeries
            .Name = Worksheets("Graph Reference").Range("AA4")
            .Values = Worksheets("Graph Reference").Range("AA13:AV13")
            .XValues = Worksheets("Graph Reference").Range("AA12:AV12")
        End With
        With myChtObj.Chart.SeriesCollection.NewSeries
            .Name = Worksheets("Graph Reference").Range("AB4")
            .Values = Worksheets("Graph Reference").Range("AA14:AV14")
            .XValues = Worksheets("Graph Reference").Range("AA12:AV12")
        End With
    The .Values property refers to the actual data being plotted against the value (Y) axis.
    The .XValues property refers to the data used on the category axis. In a column chart this would be the axis labels.
    Cheers
    Andy
    www.andypope.info

  5. #5
    Registered User
    Join Date
    08-10-2009
    Location
    Fort Collins, Colorado
    MS-Off Ver
    Excel 2003
    Posts
    29

    Re: adding column clustered chart

    That helps a bunch, thank you very much.

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