Results 1 to 3 of 3

Thread: Link a series name to a cell using Excel 2010 VBA

  1. #1

    Link a series name to a cell using Excel 2010 VBA

    Register for a FREE account, and/
    or Log in to avoid these ads!

    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

  2. #2
    Administrator Ken Puls's Avatar
    Join Date
    Mar 2011
    Nanaimo, BC, Canada
    Blog Entries
    Excel Version
    Excel Office 365 Insider
    Hi there,

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

        ActiveChart.SetElement (msoElementChartTitleAboveChart)
        Selection.Caption = "=Sheet1!R1C1"
    So basically the R1C1 is A1. B1 would be R1C2.
    Ken Puls, FCPA, FCMA, MS MVP

    Learn to Master Your Data at the Power Query Academy (the world's most comprehensive online Power Query training), with my book M is for Data Monkey, or our new Power Query Recipe cards!

    Main Site: -||- Blog: -||- Forums:
    Check out the Excelguru Facebook Fan Page -||- Follow Me on Twitter

    If you've been given VBA code (a macro) for your solution, but don't know where to put it, CLICK HERE.

  3. #3
    Thanks. This solved the problem.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts