VBA Chart Error

J

John

I keep getting HasTitle of _Chart has failed error. Any ideas?

Sub MakeChart()
On Error Resume Next
Application.DisplayAlerts = False
Charts("Term Chart").Delete
On Error GoTo 0
Set NewChart = ThisWorkbook.Charts.Add
NewChart.Name = "Term Chart"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Terms"
If FirstRange > 1 Then
NewChart.SeriesCollection.Add Source:=FirstRange
End If
If SecondRange > 1 Then
NewChart.SeriesCollection.Add Source:=SecondRange
End If
If ThirdRange > 1 Then
NewChart.SeriesCollection.Add Source:=ThirdRange
End If
End With
End Sub
 
P

Peter T

The chart needs at least one series before you can add any titles.

Regards,
Peter T
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top