Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Chart title problem

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


---
Message posted from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default Excel VBA - Chart title problem

Until you have a series, you have no plot area, no axes, and no titles.
Save this step until the end of the procedure.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Peltier Technical Services
http://PeltierTech.com/Excel/Charts/
_______

OO7_neverdie < wrote:

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


---
Message posted from http://www.ExcelForum.com/


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel VBA - Chart title problem

yes, it work... thanks alot


---
Message posted from http://www.ExcelForum.com/

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Title Block in Excel Chart - Size problem Stuart Saich Charts and Charting in Excel 1 October 25th 05 11:44 AM
chart y-axis title problem C.Woulds Charts and Charting in Excel 3 September 10th 05 01:39 AM
Excel chart - how to assign the file name in the chart title? TGreen Charts and Charting in Excel 1 August 16th 05 10:35 AM
Pasting Objects into Chart title and Axis title Sam Charts and Charting in Excel 1 June 6th 05 08:50 PM
Problem with Chart Title Formatting KvnLynch Charts and Charting in Excel 1 January 12th 05 03:15 AM


All times are GMT +1. The time now is 06:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"