secondary Y axis

E

Eric

I am trying to write a macro for two y axises. Left side is english (pounds
per cubic foot) and the right is metric. What I have now will allow me to
graph the english with no problem but when I try to add a second y axis I
then don't get any points on the graph. Can anyone help.....Here is the
macro I am using.

column S is moisture content
Column T is english version
Column U is meteric version

Range("AD7").Select
Application.CutCopyMode = False
ActiveSheet.ChartObjects("chart 7").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData Source:=Range("S19:U22"), _
PlotBy:=xlColumns
ActiveWindow.Visible = False
Range("k4").Select

'english units
ActiveSheet.DrawingObjects("chart 7").Select
ActiveSheet.ChartObjects("chart 7").Activate

With ActiveChart.Axes(xlValue)
..MinimumScale = 1
..MaximumScale = 1
..MinorUnitIsAuto = True
..MajorUnitIsAuto = True
..Crosses = xlAutomatic
..ReversePlotOrder = False
..ScaleType = False
End With
ActiveWindow.Visible = False
Range("b41").Select

'secondary axis
'With ActiveChart.Axes(xlValue, xlSecondary)
'.MaximumScale = ActiveSheet.Range("t12") * 16.01846
'.MinimumScale = ActiveSheet.Range("s12") * 16.01846

'End With


ActiveSheet.DrawingObjects("chart 7").Select
ActiveSheet.ChartObjects("chart 7").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
..MaximumScale = ActiveSheet.Range("t12")
..MinimumScale = ActiveSheet.Range("s12")
..MinorUnit = 20
..MajorUnit = 1
..Crosses = xlAutomatic
..ReversePlotOrder = False
ScaleType = False
..TickLabels.NumberFormat = "0.0"

End With


'Case Else
'End Select

'x scale
Application.ScreenUpdating = False
ActiveSheet.DrawingObjects("chart 7").Select
ActiveSheet.ChartObjects("chart 7").Activate
With ActiveChart.Axes(xlCategory)
.MaximumScale = ActiveSheet.Range("s22")
.MinimumScale = ActiveSheet.Range("s19")
.Crosses = xlAutomatic
.ReversePlotOrder = False
' .ScaleType = False
End With

End Sub
 
T

Tushar Mehta

I don't see anywhere in the code where you specify that the series
corresponding to col. U should use the secondary axis. You should do
that before you set the Secondary Axis attributes.

On Wed, 27 Aug 2008 11:36:13 -0700, Eric

I am trying to write a macro for two y axises. Left side is english
(pounds
per cubic foot) and the right is metric. What I have now will allow
me to
graph the english with no problem but when I try to add a second y
axis I
then don't get any points on the graph. Can anyone help.....Here is
the
macro I am using.

column S is moisture content
Column T is english version
Column U is meteric version

Range("AD7").Select
Application.CutCopyMode = False
ActiveSheet.ChartObjects("chart 7").Activate
ActiveChart.PlotArea.Select
ActiveChart.SetSourceData Source:=Range("S19:U22"), _
PlotBy:=xlColumns
ActiveWindow.Visible = False
Range("k4").Select

'english units
ActiveSheet.DrawingObjects("chart 7").Select
ActiveSheet.ChartObjects("chart 7").Activate

With ActiveChart.Axes(xlValue)
..MinimumScale = 1
..MaximumScale = 1
..MinorUnitIsAuto = True
..MajorUnitIsAuto = True
..Crosses = xlAutomatic
..ReversePlotOrder = False
..ScaleType = False
End With
ActiveWindow.Visible = False
Range("b41").Select

'secondary axis
'With ActiveChart.Axes(xlValue, xlSecondary)
'.MaximumScale = ActiveSheet.Range("t12") * 16.01846
'.MinimumScale = ActiveSheet.Range("s12") * 16.01846

'End With


ActiveSheet.DrawingObjects("chart 7").Select
ActiveSheet.ChartObjects("chart 7").Activate
ActiveChart.Axes(xlValue).Select
With ActiveChart.Axes(xlValue)
..MaximumScale = ActiveSheet.Range("t12")
..MinimumScale = ActiveSheet.Range("s12")
..MinorUnit = 20
..MajorUnit = 1
..Crosses = xlAutomatic
..ReversePlotOrder = False
ScaleType = False
..TickLabels.NumberFormat = "0.0"

End With


'Case Else
'End Select

'x scale
Application.ScreenUpdating = False
ActiveSheet.DrawingObjects("chart 7").Select
ActiveSheet.ChartObjects("chart 7").Activate
With ActiveChart.Axes(xlCategory)
.MaximumScale = ActiveSheet.Range("s22")
.MinimumScale = ActiveSheet.Range("s19")
.Crosses = xlAutomatic
.ReversePlotOrder = False
' .ScaleType = False
End With

End Sub

Regards,

Tushar Mehta
Microsoft MVP Excel 2000-2008
www.tushar-mehta.com
Tutorials and add-ins for Excel, PowerPoint, and other products
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top