Macro for naming a series in a chart

paul061

New Member
Joined
Aug 29, 2011
Messages
16
Hello, I have a macro for creating a chart. I'd like to have the series names come from a particular cell. I've had some help with some other things like this but can't seem to make them work the same. My programming is zero, so I've been shooting in the dark trying to make this work. This is what I've come up with but it doesn't work. I'd appreciate someone telling me how to make it work and why mine didn't work so I can begin to understand how this all is done. Thak you!

ActiveChart.SeriesCollection(3).Value = Range("B4").Value
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Thanks for the reply and sorry to seem stupid but if I want the contents of cell B7 to be the name for series 3 how would I write that?
 
Upvote 0
Hi Paul,

This would work:

Code:
ActiveChart.SeriesCollection(3).Name= Range("B7").Value

Alison
 
Upvote 0
Hmmm perhaps I'm missing something. This is what I have

Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet9").Range("H19:L24"), PlotBy _
:=xlRows
ActiveChart.SeriesCollection(3).Name = Range("B7").Value
ActiveChart.SeriesCollection(4).Name = "=""Spec Min"""
ActiveChart.SeriesCollection(5).Name = "=""Spec Max"""
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet9"
With ActiveChart

Thanks for your help!
 
Upvote 0
That will put a hard value in the Series' Name. My solution puts a formula there, so it will change if the contents of the referenced cell changes.
 
Upvote 0
Paul,

Whichever reference you use, you need to move the chart back to the sheet first - it's automatically created on a chart sheet. Move the line marked with ## as below:

Code:
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet9").Range("H19:L24"), PlotBy _
:=xlRows
## ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet9" ##
ActiveChart.SeriesCollection(3).Name = Range("B7").Value
ActiveChart.SeriesCollection(4).Name = "=""Spec Min"""
ActiveChart.SeriesCollection(5).Name = "=""Spec Max"""

Alison
 
Upvote 0
A hard value is fine. But it doesn't work. I'm getting this error
Runtime error 1004
Method range of object global failed
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,237
Members
452,898
Latest member
Capolavoro009

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