View Single Post
  #1  
Old 07-07-2008, 12:22 PM
carmennorman carmennorman is offline
Registered User
 
Join Date: 07 Jul 2008
Location: Cambridge, UK
Posts: 4
carmennorman is an unknown quantity at this point
Unhappy Excel 2007 VBA error

Hello

I hope someone can help me. I have a very simple piece of code, that works perfectly in Excel 2003, but my users have now upgraded to 2007 and the code doesn't work. I keep getting an error: Object variable not set (Error 91). But as far as I can see I have declared everything.

The code is:
Code:
Dim strWkNo As Integer
Dim strColNum As Integer

    strWkNo = InputBox("Which week number do you want to update to?", "Update Chart")
    
    strColNum = strWkNo + 1

    ActiveChart.SeriesCollection(1).XValues = "='Yields - Foam'!R3C2:R3C" & strColNum & ""
    ActiveChart.SeriesCollection(1).Values = "='Yields - Foam'!R5C2:R5C" & strColNum & ""
    ActiveChart.SeriesCollection(2).XValues = "='Yields - Foam'!R3C2:R3C" & strColNum & ""
    ActiveChart.SeriesCollection(2).Values = "='Yields - Foam'!R16C2:R16C" & strColNum & ""
The error message appears the first time I am using the variable for the activechart. Very confused , like I said it works in 2003. What do I need to do to get it working in 2007? Please help
Reply With Quote