Runtime error setting XValues property

aboons

Board Regular
Joined
Mar 14, 2007
Messages
79
Hi all,

This is my code. It's supposed to change the XValues as well as Values property of a series of charts (nmbrObjects + 1). The code generates a runtime error in the bold part.

Funny thing is that it doens't do so for x = 2, it starts when x = 3. Apparently it's something to do with the particular chart that is activated when x = 3.

Any clues?



Rich (BB code):
For x = 2 To nmbrObjects + 1

    OBJECTCOLUMN = Sheets("LookupData").Cells(5, x).Value
    Yield = 100 * (Sheets("CLEAN_DATA_PER_DATE").Cells(LAST, OBJECTCOLUMN).Value / Sheets("CLEAN_DATA_PER_DATE").Cells(FIRST, OBJECTCOLUMN).Value - 1)


    ActiveSheet.ChartObjects("Chart " & x - 1 & "").Activate
    
    With ActiveChart
        .ChartArea.Select 
        .SeriesCollection(1).XValues = _
            "=CLEAN_DATA_PER_DATE!R" & FIRST & "C77:R" & LAST & "C77"        
        .SeriesCollection(1).Values = _
            "=CLEAN_DATA_PER_DATE!R" & FIRST & "C" & OBJECTCOLUMN & ":R" & LAST &  "C" & OBJECTCOLUMN & ""
        .ChartTitle.Characters.Text = Sheets("LookupData").Cells(2, x).Value & "   " & WorksheetFunction.Round(Yield, 2) & "%"
    End With
     
Next
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

venkat1926

Well-known Member
Joined
Aug 21, 2005
Messages
4,824
Try (not tested)
.SeriesCollection(1).XValues ="CLEAN_DATA_PER_DATE!R" & FIRST & "C77:R" & LAST & "C77"

similarly for the next line
 
Upvote 0

aboons

Board Regular
Joined
Mar 14, 2007
Messages
79
Hi venkat1926 ,

Thanks, but it didn't seem to help. I have however copied the source data from chart1 and pasted it into all the other charts and now it appears to work, even if I change the variables.

I'll probably run into this one again later on, but we'll cross that bridge when we come to it.

Regards.
 
Upvote 0

Forum statistics

Threads
1,190,916
Messages
5,983,567
Members
439,849
Latest member
Tlaw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top