Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 3
Default Chart Title from Cell in Sheet1?

I am a new VBA programmer so please forgive this simple question.

I am trying to change the Title of a chart to the text in a cell on a
worksheet. This code successfully sets the title of the chart to "Stupidity":

Private Sub Chart_Activate()
Dim strChartName As String
strChartName = "stupidity"
Chart1.HasTitle = True
Chart1.ChartTitle.Text = strChartName

End Sub

I would like to replace "Stupidity" with reference to cell Sheet1!$N$1 but
cannot seem to get it to work without running into syntax errors I do not
understand.

Any help gratefully appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 3
Default Chart Title from Cell in Sheet1?

This seems to do it:

Public Sub Chart_Activate()
Dim strChartName As String
strChartName = Worksheets(1).Range("N1").value
Chart1.HasTitle = True
Chart1.ChartTitle.Text = strChartName

End Sub

Thanks.

"Mike M 91107" wrote:

I am a new VBA programmer so please forgive this simple question.

I am trying to change the Title of a chart to the text in a cell on a
worksheet. This code successfully sets the title of the chart to "Stupidity":

Private Sub Chart_Activate()
Dim strChartName As String
strChartName = "stupidity"
Chart1.HasTitle = True
Chart1.ChartTitle.Text = strChartName

End Sub

I would like to replace "Stupidity" with reference to cell Sheet1!$N$1 but
cannot seem to get it to work without running into syntax errors I do not
understand.

Any help gratefully appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 3,346
Default Chart Title from Cell in Sheet1?

Hi,

Of course you can do this by selecting the title and then clicking on the
Formula bar and typing = and then clicking on a cell in the spreadsheet.

--
If this helps, please click the Yes button

Cheers,
Shane Devenshire


"Mike M 91107" wrote:

This seems to do it:

Public Sub Chart_Activate()
Dim strChartName As String
strChartName = Worksheets(1).Range("N1").value
Chart1.HasTitle = True
Chart1.ChartTitle.Text = strChartName

End Sub

Thanks.

"Mike M 91107" wrote:

I am a new VBA programmer so please forgive this simple question.

I am trying to change the Title of a chart to the text in a cell on a
worksheet. This code successfully sets the title of the chart to "Stupidity":

Private Sub Chart_Activate()
Dim strChartName As String
strChartName = "stupidity"
Chart1.HasTitle = True
Chart1.ChartTitle.Text = strChartName

End Sub

I would like to replace "Stupidity" with reference to cell Sheet1!$N$1 but
cannot seem to get it to work without running into syntax errors I do not
understand.

Any help gratefully appreciated.

  #4   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 2,489
Default Chart Title from Cell in Sheet1?

Hi,

To create a link between cell and title text use,


Chart1.ChartTitle.Text = "='" & worksheets(1).name & "'!" & _
Worksheets(1).Range("N1").address(,,xlr1c1)

Cheers
Andy

Mike M 91107 wrote:
This seems to do it:

Public Sub Chart_Activate()
Dim strChartName As String
strChartName = Worksheets(1).Range("N1").value
Chart1.HasTitle = True
Chart1.ChartTitle.Text = strChartName

End Sub

Thanks.

"Mike M 91107" wrote:


I am a new VBA programmer so please forgive this simple question.

I am trying to change the Title of a chart to the text in a cell on a
worksheet. This code successfully sets the title of the chart to "Stupidity":

Private Sub Chart_Activate()
Dim strChartName As String
strChartName = "stupidity"
Chart1.HasTitle = True
Chart1.ChartTitle.Text = strChartName

End Sub

I would like to replace "Stupidity" with reference to cell Sheet1!$N$1 but
cannot seem to get it to work without running into syntax errors I do not
understand.

Any help gratefully appreciated.


--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
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
Using part of a cell in a chart title Nicole Charts and Charting in Excel 1 May 15th 07 09:44 AM
Chart Axis Title via cell ref. ju1eshart Charts and Charting in Excel 2 December 5th 06 02:13 PM
Chart title = cell contects Dkso Charts and Charting in Excel 4 August 27th 05 01:57 PM
Pasting Objects into Chart title and Axis title Sam Charts and Charting in Excel 1 June 6th 05 08:50 PM
how to cell reference a Chart title Rasoul Khoshravan Azar Charts and Charting in Excel 2 January 1st 05 05:00 PM


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

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

About Us

"It's about Microsoft Excel"