View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jacob Jacob is offline
external usenet poster
 
Posts: 1
Default Adding chart using a macro

Worked perfectly!

Thanks!

Jacob D.


-----Original Message-----
Sub tester1()
Columns("D:D").Select
Charts.Add
ActiveChart.ChartType = xlLine

ActiveChart.SetSourceData Source:=Sheets

("HttpStat"). _
Range("D:D"), PlotBy _
:=xlColumns

ActiveChart.Location Whe=xlLocationAsObject, _
Name:="HttpStat"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = _
"Response Time vs. Measurement Count"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory,

xlPrimary).AxisTitle.Characters.Text = _
"Measurement Count"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue,

xlPrimary).AxisTitle.Characters.Text = _
"Response Time (ms)"
End With

End Sub

Worked for me. Two changes in the code. Change Columns

("D:D") to
Range("D:D") in the SetSourceData method.

change .HasTitle = False to .HasTitle = True

--
Regards,
Tom Ogilvy

"Jacob" wrote in message
...
When I attempt to add a chart using a macro, I receive
the following error message...

Run-time error '13':
Type Mismatch

Here is a snippet of the macro...

Columns("D:D").Select
Charts.Add
ActiveChart.ChartType = xlLine
ActiveChart.SetSourceData Source:=Sheets
("HttpStat").Columns("D:D"), PlotBy _
:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject,
Name:="HttpStat"
With ActiveChart
.HasTitle = False
.ChartTitle.Characters.Text = "Response Time

vs.
Measurement Count"
.Axes(xlCategory, xlPrimary).HasTitle = True
.Axes(xlCategory,
xlPrimary).AxisTitle.Characters.Text = _
"Measurement Count"
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue,
xlPrimary).AxisTitle.Characters.Text = "Response Time
(ms)"
End With

The Macro dies on the 4th line listed. The data that

is
in column 4 is all number expect for D1 which has a

title.

Please let me know if you have any advice.

Thanks,

Jacob D.



.