Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Member
 
Posts: 70
Default Chart title: Text and Formula together? VBA

I'm trying to use Excel VBA to autocreate a chart title based on a cell value. This is what I've got so far:

Code:
.ChartTitle.Text = "Progress (as of " & "='OtherSheet'!R6C7" & ")"
It's supposed to say (as an example): Progress (as of August 28,2012)

The "August 28, 2012" is written in a cell in another sheet. I've tried double quotes, I've tried putting the = before the text and in the formula. The above code results everything written out as text, including the formula. It is just listing the formula as text, and it's not actually getting the value of that cell. Does anyone know the correct syntax to get this to work?
  #2   Report Post  
Member
 
Posts: 70
Default

Quote:
Originally Posted by KeriM View Post
I'm trying to use Excel VBA to autocreate a chart title based on a cell value. This is what I've got so far:

Code:
.ChartTitle.Text = "Progress (as of " & "='OtherSheet'!R6C7" & ")"
It's supposed to say (as an example): Progress (as of August 28,2012)

The "August 28, 2012" is written in a cell in another sheet. I've tried double quotes, I've tried putting the = before the text and in the formula. The above code results everything written out as text, including the formula. It is just listing the formula as text, and it's not actually getting the value of that cell. Does anyone know the correct syntax to get this to work?
Once again, I found a workaround; however, if someone knows how to get this working, I'm curious to know. I ended up just putting everything in another cell and then referring to that cell in my VBA.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,522
Default Chart title: Text and Formula together? VBA

On Tuesday, August 28, 2012 11:10:03 AM UTC-5, KeriM wrote:
I'm trying to use Excel VBA to autocreate a chart title based on a cell

value. This is what I've got so far:





Code:

--------------------



.ChartTitle.Text = "Progress (as of " & "='OtherSheet'!R6C7" & ")"



--------------------





It's supposed to say (as an example): Progress (as of August 28,2012)



The "August 28, 2012" is written in a cell in another sheet. I've tried

double quotes, I've tried putting the = before the text and in the

formula. The above code results everything written out as text,

including the formula. It is just listing the formula as text, and it's

not actually getting the value of that cell. Does anyone know the

correct syntax to get this to work?









--

KeriM


Try this
Sub charttitlesas()
With ActiveSheet.ChartObjects("Chart 2").Chart
..HasTitle = True
..charttitle.Characters.Text = "My Date is " & _ sheets("sheet10").Range("e1")
End With
End Sub
  #4   Report Post  
Member
 
Posts: 70
Default

Quote:
Originally Posted by Don Guillett[_2_] View Post
On Tuesday, August 28, 2012 11:10:03 AM UTC-5, KeriM wrote:
I'm trying to use Excel VBA to autocreate a chart title based on a cell

value. This is what I've got so far:





Code:

--------------------



.ChartTitle.Text = "Progress (as of " & "='OtherSheet'!R6C7" & ")"



--------------------





It's supposed to say (as an example): Progress (as of August 28,2012)



The "August 28, 2012" is written in a cell in another sheet. I've tried

double quotes, I've tried putting the = before the text and in the

formula. The above code results everything written out as text,

including the formula. It is just listing the formula as text, and it's

not actually getting the value of that cell. Does anyone know the

correct syntax to get this to work?









--

KeriM


Try this
Sub charttitlesas()
With ActiveSheet.ChartObjects("Chart 2").Chart
..HasTitle = True
..charttitle.Characters.Text = "My Date is " & _ sheets("sheet10").Range("e1")
End With
End Sub
That works! Thank you!
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic Chart title and text formula? Cecilia Charts and Charting in Excel 1 April 16th 10 01:15 PM
Chart Title = Cell Text? Ken Excel Discussion (Misc queries) 1 April 3rd 09 01:56 PM
Replacing Chart title with Text box Neil T Charts and Charting in Excel 2 June 13th 07 09:09 PM
Chart title text linked from a cell? Possible? cwinters Excel Discussion (Misc queries) 2 October 10th 05 09:28 PM
dynamic chart title text cwinters Excel Discussion (Misc queries) 2 June 9th 05 08:31 PM


All times are GMT +1. The time now is 05:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"