+ Reply to Thread
Results 1 to 2 of 2

Thread: Error: Unable to set the XValues property of the Series class

  1. #1
    Registered User
    Join Date
    09-10-2011
    Location
    San Francisco, CA
    MS-Off Ver
    Excel 2003
    Posts
    5

    Error: Unable to set the XValues property of the Series class

    I am trying to debug code written a couple years ago by someone other than me. The code is below. I am trying to loop through several worksheets and update a chart on each sheet. I get the error, "Unable to set the XValues property of the Series class".

    Sub Vlookup_formula_histogram()
    '
    ' Vlookup_histogram Macro
    ' Macro recorded 11/6/2009 by richarm1
    '
    
    '
    Dim State As String
    Dim chtObj As ChartObject
    
    For i = 1 To Worksheets(SheetA).Range("B3").Value 'Number of state and company combos
        
        If Worksheets(SheetB).Cells(i + 1, 6) = Worksheets(SheetA).Range("B5") Then
        
        State = Worksheets(SheetB).Cells(i + 1, 1)
        
        'Copy and drag the histogram formula
        Sheets(Worksheets(SheetB).Cells(i + 1, 1).Value).Select
        Range("S4").Select
        ActiveCell.FormulaR1C1 = "=VLOOKUP(RC[-1],R2C69:R23C70,2)"
        Range("S4").Select
        Selection.AutoFill Destination:=Range("S4:S" & Sheets(Worksheets(SheetB).Cells(i + 1, 1).Value).Range("X3").Value + 3)
        
        For Each chtObj In Sheets(State).ChartObjects
        
            'Change the formula for the chart
            chtObj.Activate
            ActiveChart.SeriesCollection(1).XValues = "=" & State & "!R2C70:R23C70"
            ActiveChart.SeriesCollection(1).Values = "=" & State & "!R2C71:R23C71"
            'ActiveChart.HasTitle = True
            'activechart.ChartTitle.Text =
        Next
    
        End If
    Next i
    
    End Sub
    Here is the line that is the culprit for the error:

    ActiveChart.SeriesCollection(1).XValues = "=" & State & "!R2C70:R23C70"
    Any ideas of why I might get this error and how I might fix it? Thanks!

  2. #2
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    Apparently I can't say
    MS-Off Ver
    Apparently I can't say
    Posts
    8,274

    Re: Error: Unable to set the XValues property of the Series class

    Most likely you just need single quotes round the sheet name:
    ActiveChart.SeriesCollection(1).XValues = "='" & State & "'!R2C70:R23C70"

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