Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Custom chart types; Recorded macro acts strange

I turned on the macro recorder and created a "Line on 2 Axes" chart.
The recorded macro is given below.

I ran the recorded macro but I got a different output (I think the
output was a column chart instead of "Line on 2 Axes" chart)

Why is it so? Usually macro-recorder's code works perfect. Should I
need to turn-on any references or add-ins? Someone who has a solution
for this, please clarify. Thanks

Sub Macro1()

Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Lines on 2 Axes"
ActiveChart.SetSourceData
Source:=Sheets("Sheet1").Range("A:A,C:C,D:D"), _
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = False
End With

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,582
Default Custom chart types; Recorded macro acts strange

Usually macro-recorder's code works perfect.

Not on planet Earth. Usually it gives you the right idea, but it needs
tweaking.

In any case, your recorded macro defined the chart type before there was any
data, so when you added data, the default chart type was applied. Switch the
ApplyCustomType line to after the SetSourceData line.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. - http://PeltierTech.com
_______


wrote in message
ps.com...
I turned on the macro recorder and created a "Line on 2 Axes" chart.
The recorded macro is given below.

I ran the recorded macro but I got a different output (I think the
output was a column chart instead of "Line on 2 Axes" chart)

Why is it so? Usually macro-recorder's code works perfect. Should I
need to turn-on any references or add-ins? Someone who has a solution
for this, please clarify. Thanks

Sub Macro1()

Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Lines on 2 Axes"
ActiveChart.SetSourceData
Source:=Sheets("Sheet1").Range("A:A,C:C,D:D"), _
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = False
End With

End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 106
Default Custom chart types; Recorded macro acts strange

On Oct 22, 9:23 pm, "Jon Peltier"
wrote:
Usually macro-recorder's code works perfect.


Not on planet Earth. Usually it gives you the right idea, but it needs
tweaking.

In any case, your recorded macro defined the chart type before there was any
data, so when you added data, the default chart type was applied. Switch the
ApplyCustomType line to after the SetSourceData line.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -http://PeltierTech.com
_______

wrote in message

ps.com...

I turned on the macro recorder and created a "Line on 2 Axes" chart.
The recorded macro is given below.


I ran the recorded macro but I got a different output (I think the
output was a column chart instead of "Line on 2 Axes" chart)


Why is it so? Usually macro-recorder's code works perfect. Should I
need to turn-on any references or add-ins? Someone who has a solution
for this, please clarify. Thanks


Sub Macro1()


Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Lines on 2 Axes"
ActiveChart.SetSourceData
Source:=Sheets("Sheet1").Range("A:A,C:C,D:D"), _
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = False
End With


End Sub


Jon, this is the first time I am facing the weird behavior of macros.
Btw, your trick works. Thanks.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Custom chart types; Recorded macro acts strange

On Oct 22, 9:23 pm, "Jon Peltier"
wrote:
Usually macro-recorder's code works perfect.


Not on planet Earth. Usually it gives you the right idea, but it needs
tweaking.

In any case, your recorded macro defined the chart type before there was any
data, so when you added data, the default chart type was applied. Switch the
ApplyCustomType line to after the SetSourceData line.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -http://PeltierTech.com
_______

wrote in message

ps.com...

I turned on the macro recorder and created a "Line on 2 Axes" chart.
The recorded macro is given below.


I ran the recorded macro but I got a different output (I think the
output was a column chart instead of "Line on 2 Axes" chart)


Why is it so? Usually macro-recorder's code works perfect. Should I
need to turn-on any references or add-ins? Someone who has a solution
for this, please clarify. Thanks


Sub Macro1()


Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Lines on 2 Axes"
ActiveChart.SetSourceData
Source:=Sheets("Sheet1").Range("A:A,C:C,D:D"), _
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = False
End With


End Sub


Jon, Thanks. It works.

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 115
Default Custom chart types; Recorded macro acts strange

On Oct 22, 9:23 pm, "Jon Peltier"
wrote:
Usually macro-recorder's code works perfect.


Not on planet Earth. Usually it gives you the right idea, but it needs
tweaking.

In any case, your recorded macro defined the chart type before there was any
data, so when you added data, the default chart type was applied. Switch the
ApplyCustomType line to after the SetSourceData line.

- Jon
-------
Jon Peltier, Microsoft Excel MVP
Tutorials and Custom Solutions
Peltier Technical Services, Inc. -http://PeltierTech.com
_______

wrote in message

ps.com...

I turned on the macro recorder and created a "Line on 2 Axes" chart.
The recorded macro is given below.


I ran the recorded macro but I got a different output (I think the
output was a column chart instead of "Line on 2 Axes" chart)


Why is it so? Usually macro-recorder's code works perfect. Should I
need to turn-on any references or add-ins? Someone who has a solution
for this, please clarify. Thanks


Sub Macro1()


Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Lines on 2 Axes"
ActiveChart.SetSourceData
Source:=Sheets("Sheet1").Range("A:A,C:C,D:D"), _
PlotBy:=xlColumns
ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = False
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = False
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = False
End With


End Sub


Jon, Thanks. It works.

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
Excel 2007 error "some chart types cannot be combined with other chart types. Select a different chart types" roadsidetree Charts and Charting in Excel 15 June 2nd 09 10:53 AM
Excel 2003 is missing Built-In Custom Chart Types in Chart Wizard Julius Charts and Charting in Excel 2 March 6th 09 04:43 PM
Excel 2003 is missing Built-In Custom Chart Types in Chart Wizard Julius Setting up and Configuration of Excel 1 March 6th 09 01:57 AM
built-in custom chart types Daniel Excel Discussion (Misc queries) 0 August 20th 06 07:22 PM
When code runs...worksheet acts a little strange KimberlyC Excel Programming 3 April 1st 05 04:49 PM


All times are GMT +1. The time now is 02:48 AM.

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"