Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 16
Default "Lines on 2 Axes" fails on Excel 2007

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 12/21/2007 by susaxena
'

'
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Lines on 2 Axes"
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("F31")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).AxisGroup = 1
ActiveChart.SeriesCollection(1).Values = "={4,7,3,4,5,6}"
ActiveChart.SeriesCollection(1).Name = "=""a"""
ActiveChart.SeriesCollection(2).AxisGroup = 2
ActiveChart.SeriesCollection(2).Values = "={9,3,5,7,2,8}"
ActiveChart.SeriesCollection(2).Name = "=""b"""

ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "SUMIT"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Axis on a"
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Axis on b"
End With
End Sub
This Macro works fine on Excel 2003 but fails on Excel 2007.

which charttpye will provide similar functionality on Excel 2007?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,489
Default "Lines on 2 Axes" fails on Excel 2007

Hi,

Built-in chart types are not available in xl2007.
Instead just create a Line chart with markers. Your code already has the
syntax to set the AxisGroup of each series.

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 12/21/2007 by susaxena
'

'
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("F31")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).AxisGroup = 1
ActiveChart.SeriesCollection(1).Values = "={4,7,3,4,5,6}"
ActiveChart.SeriesCollection(1).Name = "=""a"""
ActiveChart.SeriesCollection(2).AxisGroup = 2
ActiveChart.SeriesCollection(2).Values = "={9,3,5,7,2,8}"
ActiveChart.SeriesCollection(2).Name = "=""b"""

ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "SUMIT"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Axis on a"
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Axis on b"
End With
End Sub

Cheers
Andy
--

Andy Pope, Microsoft MVP - Excel
http://www.andypope.info
"Sumit" wrote in message
...
Sub Macro1()
'
' Macro1 Macro
' Macro recorded 12/21/2007 by susaxena
'

'
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Lines on 2 Axes"
ActiveChart.SetSourceData Source:=Sheets("Sheet1").Range("F31")
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection.NewSeries
ActiveChart.SeriesCollection(1).AxisGroup = 1
ActiveChart.SeriesCollection(1).Values = "={4,7,3,4,5,6}"
ActiveChart.SeriesCollection(1).Name = "=""a"""
ActiveChart.SeriesCollection(2).AxisGroup = 2
ActiveChart.SeriesCollection(2).Values = "={9,3,5,7,2,8}"
ActiveChart.SeriesCollection(2).Name = "=""b"""

ActiveChart.Location Whe=xlLocationAsObject, Name:="Sheet1"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "SUMIT"
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "Axis on a"
.Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "Axis on b"
End With
End Sub
This Macro works fine on Excel 2003 but fails on Excel 2007.

which charttpye will provide similar functionality on Excel 2007?


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
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 ronhansen Excel Discussion (Misc queries) 1 November 15th 09 09:33 PM
how i convert "100" to "hundred"( number to text) in excel-2007 mohanraj Excel Worksheet Functions 1 May 11th 08 09:07 PM
Help on adding the second trendline in a "lines on 2 axes" Chart via VBA [email protected] Charts and Charting in Excel 1 August 11th 07 02:13 PM
Help on adding the second trendline in a "lines on 2 axes" Chart by using VBA [email protected] Excel Programming 1 August 11th 07 05:03 AM
How do I format the x axis on a "lines on 2 axes" chart? Becky B Charts and Charting in Excel 1 April 5th 06 10:23 PM


All times are GMT +1. The time now is 04:33 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"