Option Box on user from to update workbook

B

Brian

I have (20) Option Boxes on a User Form that are for inputing Qty. User can
check 1 Box out of the 20. Example: If user selects Option box 601, then
changes to select option box 610. Box 601 unselects automaticaly. That is
what I want them to do.

I recorded a macro for each of the 20 Option Boxes, that makes the changes
according to Option Box selected.

Option Box Names are as follows:
Option Box = Battery_String_Qty_601
Option Boxes 602-619
Option Box = Battery_String_Qty_620

What I need to do is when User selects the option box 601-620 the Codes runs
when the Update Control Button is pushed. The User Form is a Workbook by
itself named "Master User Form".

UserForm name is "UserForm1"
Control Button is "Update_Installer_Forms_10"
Workbook being updated is "Master Installer Forms.xlsm"

I am not sure how to do this. The flow would be user picks the option box
601-620, which would tell which sub to run in the module when the Control
button is pressed.

Here is Code that I recorded to make the Changes. I have 20 Codes like this
one. 1 for each Option Box. This code is located in module1 that I moved from
the workbook.

Sub Battery_01()
'Battery_01 Macro

ActiveWindow.ScrollWorkbookTabs Position:=xlLast
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
ActiveWindow.ScrollWorkbookTabs Position:=xlLast
Sheets("Batt Chg Rpt").Select
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1:O48").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$O$48"
Range("O3:O4").Select
ActiveCell.FormulaR1C1 = "1"
Rows("49:960").Select
Selection.EntireRow.Hidden = True
ActiveWindow.SmallScroll Down:=-42
Range("G6:H7").Select
Sheets("Pilot Cell Chg Rpt").Select
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1:G67").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$G$67"
ActiveWindow.SmallScroll Down:=60
Rows("68:1340").Select
Selection.EntireRow.Hidden = True
ActiveWindow.SmallScroll Down:=-66
Range("B11:C11").Select
Sheets("Press Test Rpt").Select
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1:I1").Select
ActiveCell.FormulaR1C1 = "PRESSURE TEST RECORD"
Range("A1:I75").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$I$75"
ActiveWindow.SmallScroll Down:=60
Rows("76:1499").Select
ActiveWindow.SmallScroll Down:=-3
ActiveWindow.LargeScroll Down:=-21
ActiveWindow.SmallScroll Down:=60
Rows("76:1500").Select
Selection.EntireRow.Hidden = True
ActiveWindow.LargeScroll Down:=-1
Range("B11:E11").Select
Sheets("Batt Strap Res Rpt").Select
Cells.Select
Selection.EntireRow.Hidden = False
Range("A1:J69").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$J$69"
ActiveWindow.SmallScroll Down:=66
Rows("70:1380").Select
Selection.EntireRow.Hidden = True
ActiveWindow.LargeScroll Down:=-1
Range("H11:J11").Select
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Install Pack Con").Select
End Sub
 
B

Bob Phillips

Try

Select Case True

Case Me.Battery_String_Qty_601.Value: Call Sub Battery_01

'etc

End Select

HTH

Bob
 
B

Bob Phillips

BTW, your code can be simplified

Sub Battery_01()
'Battery_01 Macro

With Sheets("Batt Chg Rpt")
.Cells.EntireRow.Hidden = False
.PageSetup.PrintArea = "$A$1:$O$48"
.Range("O3:O4").Value = 1
.Rows("49:960").Hidden = True
End With

With Sheets("Pilot Cell Chg Rpt").Select
.Cells.EntireRow.Hidden = False
.PageSetup.PrintArea = "$A$1:$G$67"
.Rows("68:1340").Hidden = True
End With

With Sheets("Press Test Rpt").Select
.Cells.Hidden = False
.Range("A1:I1").Value = "PRESSURE TEST RECORD"
.PageSetup.PrintArea = "$A$1:$I$75"
.Rows("76:1500").Hidden = True
End With

With Sheets("Batt Strap Res Rpt").Select
.Cells.Hidden = False
.PageSetup.PrintArea = "$A$1:$J$69"
.Rows("70:1380").Hidden = True
End With
End Sub


HTH

Bob
 
B

Brian

I put the code in exactly as you have it and I am getting and Error message:
Compile Error: Expected: Identifier

'************************************************************
'Update Installer Forms Control Button
'Data Loaded from User Form to Installer Forms
'************************************************************

Private Sub Update_Installer_Forms_8_Click()

Select Case True

Case Me.Battery_String_Qty_601.Value: Call Sub Battery_01
Case Me.Battery_String_Qty_602.Value: Call Sub Battery_02
Case Me.Battery_String_Qty_603.Value: Call Sub Battery_03
Case Me.Battery_String_Qty_604.Value: Call Sub Battery_04
Case Me.Battery_String_Qty_605.Value: Call Sub Battery_05
Case Me.Battery_String_Qty_606.Value: Call Sub Battery_06
Case Me.Battery_String_Qty_607.Value: Call Sub Battery_07
Case Me.Battery_String_Qty_608.Value: Call Sub Battery_08
Case Me.Battery_String_Qty_609.Value: Call Sub Battery_09
Case Me.Battery_String_Qty_610.Value: Call Sub Battery_10
Case Me.Battery_String_Qty_611.Value: Call Sub Battery_11
Case Me.Battery_String_Qty_612.Value: Call Sub Battery_12
Case Me.Battery_String_Qty_613.Value: Call Sub Battery_13
Case Me.Battery_String_Qty_614.Value: Call Sub Battery_14
Case Me.Battery_String_Qty_615.Value: Call Sub Battery_15
Case Me.Battery_String_Qty_616.Value: Call Sub Battery_16
Case Me.Battery_String_Qty_617.Value: Call Sub Battery_17
Case Me.Battery_String_Qty_618.Value: Call Sub Battery_18
Case Me.Battery_String_Qty_619.Value: Call Sub Battery_19
Case Me.Battery_String_Qty_620.Value: Call Sub Battery_20

End Select

End Sub
 
D

Dave Peterson

Bob had a typo.

Remove that extra Sub in the Call statement:
Case Me.Battery_String_Qty_601.Value: Call Sub Battery_01
becomes:
Case Me.Battery_String_Qty_601.Value: Call Battery_01
 
B

Brian

I am sure it works, but I have a small problem. The Sub is to Large & gives
me the Error message thats it's to large. Would you look at my post on the
first page on how to break it down into Modules.

Thanks for your help
 
B

Bob Phillips

That doesn't look too large. What exact error message are you getting?

HTH

Bob
 

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