Hi, I'm referencing a user inputted variable in the data labels for a graph.
To the best of my knowledge, the only way to do the data labels is to type something similar to:
where 'Chartname'! is the chart sheet where the x labels are located. I can't do this... because "Chartname" is a user input and a changing variable everytime.Code:ActiveChart.SeriesCollection(1).XValues = "='Chartname'!$A$3:$A$11"
I don't really know what this problem is called and thus haven't been able to search for it very well... but what is the syntax for putting a user inputted variable (via text box) into something like x labels or quotes " " ?
I've tried everything, "=""'Chartname'""! etc all fail miserably...
Thanks for any help.
Last edited by Leith Ross; 06-07-2009 at 06:00 PM.
Variables do not go inside " marks else they & treated as string and not a variable
you will need something like this
Code:Dim sUserVariable As String sUserVariable = "Chartname" ActiveChart.SeriesCollection(1).XValues = "='" & sUserVariable & "'!$A$3:$A$11"
Please Read Forum Rules Before Posting
Wrap VBA code by selecting the code and clicking the # icon or Read This
How To Cross Post politely
Top Excel links for beginners to Experts
If you are pleased with a member's answer then use the Scales icon to rate it
If my reply has assistedor failed to assist you
I welcome your Feedback.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks