VBA & Line Graphs (SOLVED)

dowingc

Board Regular
Joined
Oct 27, 2002
Messages
77
I am trying to figure out how to customize the legend in a line chart. I have 4 columns of numbers that I do not/cannot have labels for what the columns are (constantly varying). When VBA builds the chart, the legend is very generic (Series1, etc), I would like to change it to read (Processor 1, Processor 2, etc). All the names for the series are in variables, just not sure how to set the series name to a variable. Thanks!!
This message was edited by dowingc on 2002-10-31 19:36
This message was edited by dowingc on 2002-11-11 00:56
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Hi dowingc,

Just select the chart, then Chart menu > Source Data... > Series Tab. In the Series listbox select the series you want the legend name for, then enter the range reference for that series' name in the Name refedit box. You can enter a range name (e.g., "=MyYrange") in this box (I assume this is what you were referring to by "variables").
 
Upvote 0
These charts are all being built automatically with VBA. There are currently approximately 12-15 charts that are made, with the program able to make around 150. I need a way for the program to set the legend as the user isn't going to be able to. I have variables in the code that are what I want the legend to read. Logically, this is what I am trying to do with the code but not sure how to properly do it in excel:

t=range("a" & servernumber).value
chart.series1.legend= t
servernumber=servernumber+1
t=range("a" & servernumber).value
chart.series2.legend=t2

This will loop until a certain condition is met (no more servers, etc)

Thanks!!
 
Upvote 0
Hi dowingc,

Here's an example that might help:

With ActiveSheet.ChartObjects(1).Chart
For servernumber = 1 To 12
.SeriesCollection(servernumber).Name = Cells(servernumber,1)
Next servernumber
End With
 
Upvote 0

Forum statistics

Threads
1,214,653
Messages
6,120,751
Members
448,989
Latest member
mariah3

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