change data range on chart

wwrightchess

New Member
Joined
Apr 20, 2022
Messages
29
Office Version
  1. 365
Platform
  1. MacOS
I am trying to change the data range on a series of charts but I get error 1004 which usually means I am missing a command. Here is the code

Sheets("GlennICE_output").Select
lr = Cells(Rows.Count, 1).End(xlUp).Row
Workbooks(partName).Activate
With Workbooks(partName).Charts("cp_plot")
.SeriesCollection(1).XValues = "C2:C" & lr
.SeriesCollection(1).Values = "P2:P" & lr
End With
The error is on
.SeriesCollection(1).XValues = "C2:C" & lr
lr is declared long and parname is a string
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
the name of the worksheet has to be in front of that address with extra characters ' and !
VBA Code:
s=sheets("Mysheet").name '----> name of the sheet with your data (in the same workbook as the chart !)
.SeriesCollection(1).XValues = "='" & s & "'!C2:C" & lr
 
Upvote 0
Solution

Forum statistics

Threads
1,214,929
Messages
6,122,315
Members
449,081
Latest member
tanurai

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