I have recorded the following VBA below. No errors in recording. Upon running the macro, however, the code errors on the bolded lines:
"Method Axes of Object_Chart failed" is the error
It's not setting up the secondary axis properly...basically, not at all even
though it recorded it. xlSecondary is a keyword for the Axes Method.
Something else I have to do to get the secondary axis working?
Thx,
DreamerZ
simplesolutions@prodigy.net
[ignore][/ignore]
"Method Axes of Object_Chart failed" is the error
Code:
Sub view_MeasurementCharts()
Charts.Add
ActiveChart.ApplyCustomType ChartType:=xlBuiltIn, TypeName:= _
"Line - Column on 2 Axes"
ActiveChart.SetSourceData Source:=Sheets("MeasurementData").Range( _
"D1:E3,M1:M3"), PlotBy:=xlColumns
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet5"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "" '//Chart Title
.Axes(xlCategory, xlPrimary).HasTitle = False
.Axes(xlValue, xlPrimary).HasTitle = True
.Axes(xlValue, xlPrimary).AxisTitle.Characters.Text = "" 'Left Axis
Title
[b].Axes(xlCategory, xlSecondary).HasTitle = False
.Axes(xlValue, xlSecondary).HasTitle = True
.Axes(xlValue, xlSecondary).AxisTitle.Characters.Text = "" 'Right
Axis Title[/b]
End With
ActiveChart.HasLegend = True
ActiveChart.Legend.Select
Selection.Position = xlBottom
[b]ActiveChart.Axes(xlValue, xlSecondary).Select
With ActiveChart.Axes(xlValue, xlSecondary)[/b]
.MinimumScale = 0
.MaximumScale = 25
.MinorUnitIsAuto = True
.MajorUnit = 5
.Crosses = xlCustom
.CrossesAt = 0
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
Selection.TickLabels.NumberFormat = "0"
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
.MinimumScale = 175
.MaximumScale = 210
.MinorUnitIsAuto = True
.MajorUnitIsAuto = True
.Crosses = xlCustom
.CrossesAt = 0
.ReversePlotOrder = False
.ScaleType = xlLinear
.DisplayUnit = xlNone
End With
End Sub
though it recorded it. xlSecondary is a keyword for the Axes Method.
Something else I have to do to get the secondary axis working?
Thx,
DreamerZ
simplesolutions@prodigy.net
[ignore][/ignore]