Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Adding chart using a macro

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.



  #2   Report Post  
Posted to microsoft.public.excel.programming
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.



.

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
Adding line chart w/ 2nd axis to stacked bar chart Greg Yedinak Charts and Charting in Excel 1 January 12th 09 10:51 PM
Adding to a Macro Steven Excel Discussion (Misc queries) 2 December 15th 08 06:21 PM
Adding % to Bar Chart Sash Charts and Charting in Excel 3 July 28th 08 09:01 PM
Adding data series to chart via macro JessK Charts and Charting in Excel 1 March 1st 06 11:04 PM
Adding a line Chart Type to a stacked-clustered Chart Type Debbie Charts and Charting in Excel 2 January 5th 05 11:25 PM


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

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

About Us

"It's about Microsoft Excel"