Err#1004 "Unable to set the XValues property of the Series class"

Please support our Visual Basic 4 / 5 / 6 advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jan 2008
Posts: 56
Reputation: Tekito is an unknown quantity at this point 
Solved Threads: 0
Tekito Tekito is offline Offline
Junior Poster in Training

Err#1004 "Unable to set the XValues property of the Series class"

 
0
  #1
Jun 11th, 2008
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:

Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. With WS.CharObjects(SelChart).Chart
  2. With .SeriesCollection(1)
  3. .XValues =DataWS.Range("A1:A101") '<-----ERROR!
  4. .Values = DataWS.Range("B1:B101")
  5. End With
  6. 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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Err#1004 "Unable to set the XValues property of the Series class"

 
0
  #2
Jun 12th, 2008
Hi,

I Guess DataWS is not set to the referring Worksheet...

Try this :
  1. With WS.CharObjects(SelChart).Chart
  2. With .SeriesCollection(1)
  3. .XValues =Sheets("Sheet1").Range("A1:A101")
  4. .Values = Sheets("Sheet1").Range("B1:B101")
  5. End With
  6. End With


Regards
Veena
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 56
Reputation: Tekito is an unknown quantity at this point 
Solved Threads: 0
Tekito Tekito is offline Offline
Junior Poster in Training

Re: Err#1004 "Unable to set the XValues property of the Series class"

 
0
  #3
Jun 12th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 848
Reputation: QVeen72 is on a distinguished road 
Solved Threads: 120
QVeen72's Avatar
QVeen72 QVeen72 is offline Offline
Practically a Posting Shark

Re: Err#1004 "Unable to set the XValues property of the Series class"

 
0
  #4
Jun 13th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 56
Reputation: Tekito is an unknown quantity at this point 
Solved Threads: 0
Tekito Tekito is offline Offline
Junior Poster in Training

Re: Err#1004 "Unable to set the XValues property of the Series class"

 
0
  #5
Jun 13th, 2008
Yeah, so it appears... I've pretty much resigned to finding workarounds. I really am not very fond of Excel charts.
Reply With Quote Quick reply to this message  
Join Date: Nov 2009
Posts: 1
Reputation: shikeh is an unknown quantity at this point 
Solved Threads: 0
shikeh shikeh is offline Offline
Newbie Poster

clumsy solution, but work

 
0
  #6
31 Days Ago
Hi
I found that this bug cause the program not working only when you do a presentation in front of managers. then it crash
but my solution for this is to run-over all the range (or array, in my case) and make it a string
this is the code for the string (pointing every time on Reported (N):
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ReportedString = ReportedString & Chr(&H22) & Reported(N) & Chr(&H22) & ","
we need this Chr function because we need to insert string as the Xvalue (and we can just like that add ' " ')
after that, remove the last "," by this code:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ReportedString = Left(ReportedString, Len(ReportedString) - 1)
then, the last one is to add the brackets:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. ReportedString = "={" & ReportedString & "}"
after this, just:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
  1. .XValues= ReportedString
Hope it will help you (it helpd me )
Shikeh
Reply With Quote Quick reply to this message  
Reply

Message:



Other Threads in the Visual Basic 4 / 5 / 6 Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC