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
 

Excel Facts

What do {} around a formula in the formula bar mean?
{Formula} means the formula was entered using Ctrl+Shift+Enter signifying an old-style array formula.
Change:

Public Sub AlginY(FreeParam As Integer)

To:

Public Sub AlignY(FreeParam As Integer)
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top