Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel Chart has no title error

Tags:

excel

vba

charts

I'm working with VBA trying to make charts. The chart is created like it should, but when I try to define a title, I get this error: "run time error '-2147024809 (80070057): this object has no title."

my VBA line is:

ActiveChart.ChartTitle.Text = "From " & Cells(Start, Prev) & " To " & Cells(Start, Op) & " - Recomended Setup: 0"

Does anyone has any idea why It's not working? (the same line worked on another chart already...) Thank you!

like image 638
Bramat Avatar asked Sep 11 '14 13:09

Bramat


People also ask

How do I insert title in Excel chart?

Click on the DESIGN tab. Open the drop-down menu named Add Chart Element in the Chart Layouts group. If you work in Excel 2010, go to the Labels group on the Layout tab. Choose 'Chart Title' and the position where you want your title to display.

How do you link a chart title to a cell?

In the formula bar, type an equal sign (=). In the worksheet, select the cell that contains the data that you want to display in the title, label, or text box on the chart. Press ENTER.


1 Answers

That is because you need to create the title before you can set it. Add this line before your code

ActiveChart.HasTitle = True
ActiveChart.ChartTitle.Text = "From " & Cells(Start, Prev) & _
                              " To " & Cells(Start, Op) & _
                              " - Recomended Setup: 0"
like image 92
Siddharth Rout Avatar answered Sep 27 '22 18:09

Siddharth Rout