Link a series name to a cell using Excel 2010 VBA

KGL

New member
Joined
Feb 3, 2012
Messages
2
Reaction score
0
Points
0
I am trying to create a chart in Excel 2010 using VBA. Adding the X and Y values works fine, but for the series name it applies the text currently in the cell instead of a link to the cell. In this case the series label may change depending on user input, so I need to link to the cell instead of assign a fixed string value. Is there any way to do this? It is simple enough doing it manually in the worksheet, but I can't seem to figure out how to do it in VBA. My basic code is shown below.

With srsNew
.Name = ActiveSheet.Cells(N, ColNum)
.Values = ActiveSheet.Range(Cells(N, ColNum + 1), Cells(N,ColNum + 2))
.XValues = ActiveSheet.Range(RFRAngeAddr)
...

Thanks for any advice
 

Ken Puls

Administrator
Staff member
Joined
Mar 13, 2011
Messages
2,521
Reaction score
6
Points
38
Location
Nanaimo, BC, Canada
Website
www.excelguru.ca
Excel Version(s)
Excel Office 365 Insider
Hi there,

I recorded linking the title to a cell and it came back with the following. Does this help?

Code:
    ActiveChart.SetElement (msoElementChartTitleAboveChart)
    Selection.Caption = "=Sheet1!R1C1"

So basically the R1C1 is A1. B1 would be R1C2.
 

KGL

New member
Joined
Feb 3, 2012
Messages
2
Reaction score
0
Points
0
Thanks. This solved the problem.
 
Top