O
OO7_neverdie
Hi all,
I am programming a command button to graph a chart but i recieve an
error at ".Hastitle = True" all the time. Would you guys please look
at them and what wrong with the code. Thank very much your help.
=============================================
Private Sub CommandButton2_Click()
Dim NameCheck As Boolean
Dim NewChart As Chart
NameCheck = False
For i = 1 To Charts.count
If Charts(i).Name = "Chart" Then
NameCheck = True
End If
Next i
If NameCheck = False Then
Set NewChart = Charts.Add
NewChart.Name = "Chart"
Else
Set NewChart = Charts("Chart")
End If
NewChart.Activate
With ActiveChart
..ChartType = xlXYScatter
..HasTitle = True <===========================
..ChartTitle.Text = "Value Distribution Chart"
..ChartArea.ClearContents
..HasLegend = True
With ActiveChart.Axes(xlValue)
..HasTitle = True
With .AxisTitle
..Caption = "Revenue (millions)"
..Font.Name = "bookman"
..Font.Size = 10
..Characters(10, 8).Font.Italic = True
End With
End With
End With
For i = 1 To Worksheets.count
If Worksheets(i).Name <> "Good" Then
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i).XValues =
Worksheets(i).Cells(8, 5)
ActiveChart.SeriesCollection(i).Values = Worksheets(i).Cells(8,
6)
ActiveChart.SeriesCollection(i).Name = Worksheets(i).Cells(1,
1)
End If
Next i
I am programming a command button to graph a chart but i recieve an
error at ".Hastitle = True" all the time. Would you guys please look
at them and what wrong with the code. Thank very much your help.
=============================================
Private Sub CommandButton2_Click()
Dim NameCheck As Boolean
Dim NewChart As Chart
NameCheck = False
For i = 1 To Charts.count
If Charts(i).Name = "Chart" Then
NameCheck = True
End If
Next i
If NameCheck = False Then
Set NewChart = Charts.Add
NewChart.Name = "Chart"
Else
Set NewChart = Charts("Chart")
End If
NewChart.Activate
With ActiveChart
..ChartType = xlXYScatter
..HasTitle = True <===========================
..ChartTitle.Text = "Value Distribution Chart"
..ChartArea.ClearContents
..HasLegend = True
With ActiveChart.Axes(xlValue)
..HasTitle = True
With .AxisTitle
..Caption = "Revenue (millions)"
..Font.Name = "bookman"
..Font.Size = 10
..Characters(10, 8).Font.Italic = True
End With
End With
End With
For i = 1 To Worksheets.count
If Worksheets(i).Name <> "Good" Then
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(i).XValues =
Worksheets(i).Cells(8, 5)
ActiveChart.SeriesCollection(i).Values = Worksheets(i).Cells(8,
6)
ActiveChart.SeriesCollection(i).Name = Worksheets(i).Cells(1,
1)
End If
Next i