ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Unable to set XValues Property of Series Class (https://www.excelbanter.com/excel-programming/361492-unable-set-xvalues-property-series-class.html)

DynamiteSkippy

Unable to set XValues Property of Series Class
 
I am using a variable to dictate which chart series I am working with however
I am recieving the following error:

Run-time error '1004'
Unable to set XValues property of Series Class

My code looks like:
Dim StrtRng, i As Long

'Redirect Chart Elements
TierVar = Range(Comp3Tier.Address).Value 'ActiveCell.Offset(0,
(Comp3Tier.Column - CostRng.Column)).Value

With Charts(activesheet.Name & "_Chart")
'RngStrg
..SeriesCollection(TierVar).XValues = "=DataSheet!R" & StrtRng & "C5:R" & i &
"C5"
..SeriesCollection(TierVar).Values = "=DataSheet!R" & StrtRng & "C6:R" & i &
"C6"
..SeriesCollection(5).XValues = "=DataSheet!R" & i & "C7:R" & (i + 1) & "C7"
..SeriesCollection(5).Values = "=DataSheet!R" & i & "C8:R" & (i + 1) & "C8"
..SeriesCollection(4).XValues = "=DataSheet!R" & i & "C9:R" & (i + 1) & "C9"
..SeriesCollection(4).Values = "=DataSheet!R" & i & "C10:R" & (i + 1) & "C10"
..SeriesCollection(6).XValues = "=DataSheet!R" & i & "C11:R" & (i + 1) & "C11"
..SeriesCollection(6).Values = "=DataSheet!R" & i & "C12:R" & (i + 1) & "C12"
..SeriesCollection(7).XValues = "=DataSheet!R" & i & "C13:R" & (i + 1) & "C13"
..SeriesCollection(7).Values = "=DataSheet!R" & i & "C14:R" & (i + 1) & "C14"
End With
StrtRng = i + 1
End If
ActiveCell.Offset(1, 0).Activate
i = i + 1

Loop

Jon Peltier

Unable to set XValues Property of Series Class
 
Make sure the range contains valid data. Also, I doubt that it matters, but
I invariably define the Y values first.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
http://PeltierTech.com
_______


"DynamiteSkippy" wrote in message
...
I am using a variable to dictate which chart series I am working with
however
I am recieving the following error:

Run-time error '1004'
Unable to set XValues property of Series Class

My code looks like:
Dim StrtRng, i As Long

'Redirect Chart Elements
TierVar = Range(Comp3Tier.Address).Value 'ActiveCell.Offset(0,
(Comp3Tier.Column - CostRng.Column)).Value

With Charts(activesheet.Name & "_Chart")
'RngStrg
.SeriesCollection(TierVar).XValues = "=DataSheet!R" & StrtRng & "C5:R" & i
&
"C5"
.SeriesCollection(TierVar).Values = "=DataSheet!R" & StrtRng & "C6:R" & i
&
"C6"
.SeriesCollection(5).XValues = "=DataSheet!R" & i & "C7:R" & (i + 1) &
"C7"
.SeriesCollection(5).Values = "=DataSheet!R" & i & "C8:R" & (i + 1) & "C8"
.SeriesCollection(4).XValues = "=DataSheet!R" & i & "C9:R" & (i + 1) &
"C9"
.SeriesCollection(4).Values = "=DataSheet!R" & i & "C10:R" & (i + 1) &
"C10"
.SeriesCollection(6).XValues = "=DataSheet!R" & i & "C11:R" & (i + 1) &
"C11"
.SeriesCollection(6).Values = "=DataSheet!R" & i & "C12:R" & (i + 1) &
"C12"
.SeriesCollection(7).XValues = "=DataSheet!R" & i & "C13:R" & (i + 1) &
"C13"
.SeriesCollection(7).Values = "=DataSheet!R" & i & "C14:R" & (i + 1) &
"C14"
End With
StrtRng = i + 1
End If
ActiveCell.Offset(1, 0).Activate
i = i + 1

Loop




DynamiteSkippy

Unable to set XValues Property of Series Class
 
I should mention that I initially had no problems with this code and this
issue only arises occasionally and I haven't figured out the rhyme or reason
why it occasionally works. I have played around with it several different
ways and each time the data is valid [numerical] and I tried changing order
of .xvalues and .values statements, but still this occurs no matter which
statement is first.

Does anyone know if I should be using the .formula method rather than .value
? Any ideas??

-D



All times are GMT +1. The time now is 11:41 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com