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
    Location
    Nanaimo, BC, Canada
    Posts
    2,208
    Articles
    57
    Blog Entries
    14
    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.
    Ken Puls, FCPA, FCMA, MS MVP (Excel)

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

    Main Site: http://www.excelguru.ca -||- Blog: http://www.excelguru.ca/blog -||- Forums: http://www.excelguru.ca/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
  •