Err#1004 "Unable to set the XValues property of the Series class"
This is an issue that I've discusses many times before, but never with a conclusive solution. I am trying to programmatically change the data range for an existing chart in Excel. My code goes something like this:
With WS.CharObjects(SelChart).Chart
With .SeriesCollection(1)
.XValues =DataWS.Range("A1:A101") '<-----ERROR!
.Values = DataWS.Range("B1:B101")
End With
End With
The .XValues line results in the "1004 Unable to set the XValues property of the Series class" error. The range contains valid data: numbers, no blanks. When I manually set the chart to this range, everything is fine. Like I said, I've read many people having this problem, but nothing is working for me. I've had no end of trouble dealing with Excel charts. Sometimes they work, sometimes they don't.
Tekito
Junior Poster in Training
56 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Hi,
I Guess DataWS is not set to the referring Worksheet...
Try this :
With WS.CharObjects(SelChart).Chart
With .SeriesCollection(1)
.XValues =Sheets("Sheet1").Range("A1:A101")
.Values = Sheets("Sheet1").Range("B1:B101")
End With
End With
Regards
Veena
QVeen72
Veteran Poster
1,017 posts since Nov 2006
Reputation Points: 118
Solved Threads: 164
Skill Endorsements: 5
The data columns and graph are on two different worksheets. I have tried explicitly naming the worksheets (which shouldn't make any difference) and other trivial syntax variations, but nothing works.
Tekito
Junior Poster in Training
56 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0
Hi,
Well.. I Guess, after Googling with the error said, it appears that, it is a BUG in Excell 2k. Not sure, if the higher versions of Excel have been cleared of that bug..
Regards
Veena
QVeen72
Veteran Poster
1,017 posts since Nov 2006
Reputation Points: 118
Solved Threads: 164
Skill Endorsements: 5
Yeah, so it appears... I've pretty much resigned to finding workarounds. I really am not very fond of Excel charts.
Tekito
Junior Poster in Training
56 posts since Jan 2008
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0