Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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
Posted to microsoft.public.excel.programming
|
|||
|
|||
"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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Selecting "Save As" adds "Copy of" to file name- MS Excel 2007 | Excel Discussion (Misc queries) | |||
how i convert "100" to "hundred"( number to text) in excel-2007 | Excel Worksheet Functions | |||
Help on adding the second trendline in a "lines on 2 axes" Chart via VBA | Charts and Charting in Excel | |||
Help on adding the second trendline in a "lines on 2 axes" Chart by using VBA | Excel Programming | |||
How do I format the x axis on a "lines on 2 axes" chart? | Charts and Charting in Excel |