Hello,
I would like my chart title to automatically be the value of what is in cell A1.
ive triedbut that doesnt work.Formula:Please Login or Register to view this content.
is this even possible?
Hello,
I would like my chart title to automatically be the value of what is in cell A1.
ive triedbut that doesnt work.Formula:Please Login or Register to view this content.
is this even possible?
you have to enter that in the formula bar. 1st, click on the "chart title" on the chart, then type on (or copy) the reference into the formula bar
1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
2. If your question is resolved, mark it SOLVED using the thread tools
3. Click on the star if you think someone helped you
Regards
Ford
thanks.
if i want a word after the cell's value, how would i put that in the formula?
isnt working for meFormula:Please Login or Register to view this content.
Last edited by tlacloche; 03-26-2013 at 07:10 PM.
You need to add the text in the cell being linked to.
The link itself can only contain a reference to cell(s)
Double Post!, so much for new server
You need to add the text in the cell being linked to.
The link itself can only contain a reference to cell(s)
you can also use a named formula but you have to set the formula up to point to a cell first and then amend it after linking the chart title to it
Josie
if at first you don't succeed try doing it the way your wife told you to
can you elaborate a little more please JosephP. i dont quite understand.
sure thing
1. create a named range that refers to the cell you want to use-say you call it MyChartTitle and refer to =Sheet1!$A$1
2. link the chart title to the name using =Sheetname!MyChartTitle
3. edit the named range to refer to =Sheet1!$A$1&" more text"
thats all well and good JosephP, but I have many charts which i want to link to cell A1. however each chart has a different text after the A1 value.
for example, my first chart will have A1 value followed by "Profits". My next chart will have A1 value followed by "Sales" and so on.
Then I would suggest that you create a table containing A1 and then all the other text you want following A1 - then use those new references in your chart
that defeats the purpose. I may as well manually title the charts.
my plan is to make many duplications of this sheet so all i need to do is change A1 on each sheet and it will give me my desired chart title.
hope that makes sense.
ok good luck
Don't you know how to do it then?
I offered a suggestion which you didnt like, maybe some-one else can offer a better 1
its not that i didnt like it. it just doesnt work for me.
dont take it personally. i appreciate your effort
Can you not use ActiveSheet.Range("A1").text and use the worksheet activate event to add the chart title ?
i dont understand Coreytroy.
Could you elaborate further please...
Right click on the tab and select View Code
At the top right select worksheet Activate event
Add the following before End Sub
Change Chart 1 to chart name to suit.Please Login or Register to view this content.
doesnt work for me. i get a macro error that gives me the options of debug and end.
anyone else....
This will change the title's text to a value in cell A1.Please Login or Register to view this content.
Last edited by dagagnon; 04-03-2013 at 01:36 PM.
will this allow me to title my charts with the A1 value followed by a text of my choice (e.g. Graph).
so when the sheet is duplicated the first word of the chart title will be the A1 value, and the second word is Graph
the named range method would-you simply create a different name to use with each chart title
you could also use two textboxes-one linked to A1 and the other containing your static text for each chart. if the charts are embedded on the sheet you could also use cells above the charts to contain the titles
i have the following macro on the sheet.
i dont know where to add the chart title macro.Please Login or Register to view this content.
Please Login or Register to view this content.
Last edited by coreytroy; 04-06-2013 at 07:41 PM.
thanks coreytroy.
that puts the A1 cell value in the chart title, but where in the macro do i insert my text of choice? or do i do that manually on the chart title?
I think you may have to use an Inputbox for the added text.
Untested code.Please Login or Register to view this content.
we're getting there...
however, every time i visit the sheet and the macro is applied, a small box appears asking me to enter the required text. it doesn't automatically add the text from the macro into the chart title.
any ideas why?
Last edited by tlacloche; 04-10-2013 at 08:58 AM.
The code should set the chart title as what is in cell A1, and what text was entered into the inputbox.
Isn't that what you were after?
See example file.
maybe you're not getting the same thing i am...
if i visit "sheet 2", then go back to "sheet 1", the small box appears asking me to enter the text i want in the chart title. this happens each time i visit "sheet 1", even after I have already filled in the box the last time i visited the sheet.
i want the sheet to already know what text i want directly from the macro. i dont want to keep inputting the text in the small box every time i click on "sheet 1"
Last edited by tlacloche; 04-10-2013 at 07:33 PM.
So the actual text added to the cell value will not change, and is fixed ?
If the added text will ALWAYS be fixed, then try the below, by changing the 'Additional text - fixed' with what you want to add to the cell value.
Untested.
Please Login or Register to view this content.
doesnt work.
getting a "Compile error. Syntax error."
For some reason the debugger highlights the first line in yellow - "Private Sub Worksheet Activate ( )"
that's not what the first line said-did you copy and paste it?
it is the first line. look at the code Coreytroy posted above my post. "Private Sub Worksheet Activate ( )" is the first line.
no it isn't-read it carefully ;-)
i think i know where the confusion is.
i already had the following macro
coreytroy was giving me his chart title macro combined with the one i already have.Please Login or Register to view this content.
"Private Sub Worksheet Activate ( )" has always been the first line of my macro and will continue to be.
nope-there's an underscore between Worksheet and Activate otherwise the syntax would be invalid and it wouldn't compile
yes ive included that. i did copy and paste the code
no underscore there and that would produce the syntax error you describedFor some reason the debugger highlights the first line in yellow - "Private Sub Worksheet Activate ( )"
there is an underscore there. please see the attached file which shows a screenshot.
after i click OK on the syntax error box this is what it looks like:
then it would have helped if you posted the actual code that is present
the error is in the line highlighted in red
should be one wordPlease Login or Register to view this content.
changed that but now get a box with "Compile error: Else without if".
The word "Else" is highlighted.
Here's the code:
Please Login or Register to view this content.
needs to be two lines if you have an else sectionPlease Login or Register to view this content.
Please Login or Register to view this content.
made the changes and there are no errors HOWEVER the word "profits" is not on the chart title
here's the code:
Please Login or Register to view this content.
there's nothing in that code to add the word 'profits'-it only checks if it's there already. I reckon you want
Please Login or Register to view this content.
wow. you got it. thank you so much.
just out of curiosity, if i wanted to also do the same with chart 2 and chart 3 but instead of the word "profits" i want "sales" and "cost" how would i add it to your macro?
one way would be like this
Please Login or Register to view this content.
i probably should have mentioned that the chart names are not simply 1, 2, 3.....
its more like chart 1, chart 5, chart 11, chart 13.....
can your macro work with that?
not without some way of identifying which chart gets which title
assuming you know the names in advance, perhaps
Please Login or Register to view this content.
Last edited by JosephP; 04-11-2013 at 11:06 AM. Reason: tweak
is it not possible to duplicate the following and replace "chart 1" with the correct chart number:
im afraid my excel knowledge is a fraction of yours. i appreciate your patience and time matePlease Login or Register to view this content.
see the amendment I made to the last post-you just need to make sure the elements in each array are in the same order
i input the following but only the first 3 charts are changing:
Please Login or Register to view this content.
sorry-I actually changed the code again in case you had more than 3 charts but I think you got the code before I changed it
YES!!!!
thank you!!!!
one last last thing.
on my other sheets i have used the following code to protect the sheet (as well as the autofilter:
however, on your code youve used the following lines of code:Please Login or Register to view this content.
Please Login or Register to view this content.
Please Login or Register to view this content.
whats the difference between the two?Please Login or Register to view this content.
no functional difference but if you change the password you only have to do it in one place using my code ;-)
got it.
thanks again
you're welcome
Took a while, but a win none the less.
Last edited by coreytroy; 04-11-2013 at 04:36 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks