Selecting a range dynamically for a chart

NewOrderFac33

Well-known Member
Joined
Sep 26, 2011
Messages
1,283
Office Version
  1. 2016
  2. 2010
Platform
  1. Windows
Good afternoon,

I'm attempting to re-use some code that I've used successfully previously to define the ranges to be used by a chart embedded in a worksheet.
Code:
 Dim Chart_Modal As Chart
 Set Chart_Modal = ModalSheet.ChartObjects("HR_Modal").Chart
 'Sets the Modal chart based on the Col_HR_CAPI_ ranges + defines legend.
 Chart_Modal.SetSourceData Source:=Range("XLabels,RangeA,RangeB,RangeC,RangeD,Range5")
 Chart_Modal.SeriesCollection(1).Name = "=""A"""
 Chart_Modal.SeriesCollection(2).Name = "=""B"""         *
 Chart_Modal.SeriesCollection(3).Name = "=""C"""
 Chart_Modal.SeriesCollection(4).Name = "=""D"""
 Chart_Modal.SeriesCollection(5).Name = "=""E"""
However, when it hits the line I've marked with an asterisk, the code stops with the error "Run-time error '1004': Invalid Parameter
All the named ranges exist and they are all the same size.
Can anyone suggest where I might be going wrong?
Thanks in advance
Pete

However
 
Last edited:

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
Sorted now - thread can be closed - thanks to everyone who took a look.
 
Upvote 0

Forum statistics

Threads
1,224,885
Messages
6,181,588
Members
453,055
Latest member
cope7895

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