ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Chart Error (https://www.excelbanter.com/excel-programming/410887-vba-chart-error.html)

John

VBA Chart Error
 
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

Peter T

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

Regards,
Peter T

"John" wrote in message
...
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





All times are GMT +1. The time now is 11:06 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com