Bramat
Bramat

Reputation: 997

Excel Chart has no title error

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!

Upvotes: 7

Views: 7826

Answers (1)

Siddharth Rout
Siddharth Rout

Reputation: 149295

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"

Upvotes: 14

Related Questions