chart title and axis titles

ilFonta

New Member
Joined
Dec 25, 2012
Messages
6
Dear community
My name is Giacomo and you can consider me an Excel-VBA dummy.
I'm trying to learn VBA and in the meantime I have problem also with naming my chart:(.
This is the list I wrote to prduce a little chart.
Sub grafico()
Dim WS As Worksheet
Set WS = Worksheets("Sheet1")
WS.Shapes.AddChart.Select
ActiveChart.SetSourceData Source:= WS.Range("F6:F9")
ActiveChart.ChartType = xlXYScatter
End Sub

It works good, but I would like to put the title on top.
I tryied with
ActiveChart.ChartTitle.Caption = "My Chart"
or
ActiveChart.ChartTitle.Text = "My Chart"
but both my attempts don't work.
Any suggestions?
Thank you very much
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Try

Code:
ActiveChart.HasTitle = True
ActiveChart.ChartTitle.Text = "George"
 
Upvote 0
Thank you very much!
Anyway I solve the problem later doing some experiments with the macro recorder and checking the VBA code producted.

Finally it is possible to give a name to a chart also writing this two instructions after the series declaration.

Code:
ActiveChart.SetElement (msoElementChartTitleAboveChart)
    Selection.Caption = "MyChart"
 
Upvote 0

Forum statistics

Threads
1,214,613
Messages
6,120,515
Members
448,968
Latest member
Ajax40

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top