logistic311
New Member
- Joined
- Jun 26, 2009
- Messages
- 2
I copied this code from the following website but am unable to get it to actually work.
http://peltiertech.com/Excel/Charts/AlignXon2Ys.html
I keep getting a compile error saying sub or function not defined. Please help.
Thanks!
Option Explicit
'''Realign Macro Helper
Public Sub AlignYPrimaryMinimum()
AlignY 1
End Sub
Public Sub AlignYPrimaryMaximum()
AlignY 2
End Sub
Public Sub AlignYSecondaryMinimum()
AlignY 3
End Sub
Public Sub AlignYSecondaryMaximum()
AlignY 4
End Sub
'''The Realigner
Public Sub AlginY(FreeParam As Integer)
'''FreeParm: Axis Allowed to Vary
''' 1: Y1 (PRI) MIN
''' 2: Y1 (PRI) MAX
''' 3: Y2 (SEC) MIN
''' 4: Y2 (SEC) MAX
Dim Y1min As Double
Dim Y1max As Double
Dim Y2min As Double
Dim Y2max As Double
With ActiveChart
With .Axes(2, 1)
Y1min = .MinimumScale
Y1max = .MaximumScale
.MinimumScaleIsAuto = False
.MaximumScaleIsAuto = False
End With
With .Axes(2, 2)
Y2min = .MinimumScale
Y2max = .MaximumScale
.MinimumScaleIsAuto = False
.MaximumScaleIsAuto = False
End With
Select Case FreeParam
Case 1
If Y2max <> 0 Then .Axes(2, 1).MinimumScale = Y2min * Y1max / Y2max
Case 2
If Y2min <> 0 Then .Axes(2, 1).MaximumScale = Y1min * Y2max / Y2min
Case 3
If Y1max <> 0 Then .Axes(2, 2).MinimumScale = Y1min * Y2max / Y1max
Case 4
If Y1min <> 0 Then .Axes(2, 2).MaximumScale = Y2min * Y1max / Y1min
End Select
End With
End Sub
http://peltiertech.com/Excel/Charts/AlignXon2Ys.html
I keep getting a compile error saying sub or function not defined. Please help.
Thanks!
Option Explicit
'''Realign Macro Helper
Public Sub AlignYPrimaryMinimum()
AlignY 1
End Sub
Public Sub AlignYPrimaryMaximum()
AlignY 2
End Sub
Public Sub AlignYSecondaryMinimum()
AlignY 3
End Sub
Public Sub AlignYSecondaryMaximum()
AlignY 4
End Sub
'''The Realigner
Public Sub AlginY(FreeParam As Integer)
'''FreeParm: Axis Allowed to Vary
''' 1: Y1 (PRI) MIN
''' 2: Y1 (PRI) MAX
''' 3: Y2 (SEC) MIN
''' 4: Y2 (SEC) MAX
Dim Y1min As Double
Dim Y1max As Double
Dim Y2min As Double
Dim Y2max As Double
With ActiveChart
With .Axes(2, 1)
Y1min = .MinimumScale
Y1max = .MaximumScale
.MinimumScaleIsAuto = False
.MaximumScaleIsAuto = False
End With
With .Axes(2, 2)
Y2min = .MinimumScale
Y2max = .MaximumScale
.MinimumScaleIsAuto = False
.MaximumScaleIsAuto = False
End With
Select Case FreeParam
Case 1
If Y2max <> 0 Then .Axes(2, 1).MinimumScale = Y2min * Y1max / Y2max
Case 2
If Y2min <> 0 Then .Axes(2, 1).MaximumScale = Y1min * Y2max / Y2min
Case 3
If Y1max <> 0 Then .Axes(2, 2).MinimumScale = Y1min * Y2max / Y1max
Case 4
If Y1min <> 0 Then .Axes(2, 2).MaximumScale = Y2min * Y1max / Y1min
End Select
End With
End Sub