Reputation: 401
I want to make cell A1 as chart title. I used the given below code. But it didn't worked.
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.ChartTitle.Text = "HSI of" & Cells(1, 1).Value
I want the chart title as "HSI of" "*******cell value(in my case A1)**********"
Upvotes: 1
Views: 9331
Reputation: 37119
Your second line of code looks good. Let's see if you can tweak the first line to get the desired results. Try this, assuming your chart is the first one in the active sheet:
ActiveSheet.ChartObjects(1).Activate
ActiveChart.ChartTitle.Text = "HSI of " & Cells(1,1).Value
This code activates the first chart object in your current sheet and then changes the title.
Upvotes: 1
Reputation: 4047
Please set the HasTitle
property of the chart to True
before assigning the title.
ActiveChart.HasTitle = True
ActiveChart.SetElement (msoElementChartTitleAboveChart)
ActiveChart.ChartTitle.Text = "HSI of " + Cells(1, 1).Value
Upvotes: 2