Error - method xvalues of object series fails

spurs

Active Member
Joined
Oct 18, 2006
Messages
479
Office Version
  1. 2016
  2. 2013
  3. 2010
  4. 2007
  5. 2003 or older
Platform
  1. Windows
I have VBA code that has worked previously in excel 2007. I am now upgrading to excel 2010 but need compatability with excel 2003 - 2010.

I am getting the error
Method xvalues of object series faild when executing code for charting

the code is as follows:

With Sheets("CD-TR Chart").ChartObjects("Chart 1").Chart
.SetSourceData Source:=Sheets("Data").Range("A1:A" & Nreadings), PlotBy:=xlColumns
With .SeriesCollection(1)
.XValues = Worksheets("Data").Range("A1:A" & Nreadings)
.Values = Worksheets("Data").Range("B1:B" & Nreadings)
.Name = "Center Distance"
.Border.ColorIndex = 11
.Border.Weight = xlThin
.Border.LineStyle = xlContinuous
End With
End With


The error occurs on line
.XValues = Worksheets("Data").Range("A1:A" & Nreadings)

A few lines before the code
Worksheets("Data").Range("A1:J" & Nreadings) = Data
executed fine so I know it is not a declaration issue or something like that

Any suggestions on how to make this more stable across all versions of excel vba?
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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
Back
Top