Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start userform multipage into a specific page

I have a Userform named SheetBox

SheetBox contains a 3-page multipage window

"page1" for selecting sheets to import
"page2" contains a pseudo progress bar
"page3" for selecting sheets to protect

What I need now is a method to open a specific page upon opening the Userform when a button on a worksheet is clicked

ex:
ImportBttn opens page1 of userform
ProtctBttn opens page3 of userform

I'm doing this to reduce the number of userform I needed to create, instead of creating 3 separate userforms. This also helps reduce the filesize.

like image 346
forums Avatar asked Feb 12 '13 06:02

forums


People also ask

How do you select a page in a MultiPage VBA Excel?

To select a page tab, you use its Value property. So to select the first page tab of the control you would write. Remember that MultiPage1 is the name of our MultiPage control, and you can change this property. And to select the second page tab of the control you would write.

How do I use a MultiPage UserForm?

Add Multiple Pages to a UserFormSelect the MultiPage control from the Toolbox. (If you don't see the toolbox, click the form and go to View > Toolbox in the top navigation menu). Click and drag your mouse on the form to place the MultiPage control.

Can you duplicate Userforms?

Sure, you can duplicate an Excel UserForm manually: Rename the UserForm to the desired new UserForm name. Export the UserForm. Rename the UserForm back to its original name.


2 Answers

This works too

Sub ImportBttn_Click()
Load SheetBox: SheetBox.MultiPage1.Value = 0: SheetBox.Show
End Sub

Sub ProtctBttn_Click()
Load SheetBox: SheetBox.MultiPage1.Value = 2: SheetBox.Show
End Sub

this loads sheetbox first, changes the multipage page and shows it afterwards

but thanks for the caller method, will be useful when I need to know what button gets pressed

like image 118
forums Avatar answered Nov 15 '22 09:11

forums


In the UserForms Initialise Event, use Application.Caller to detect which button on the worksheet was pressed, and then set the multipage

Private Sub UserForm_Initialize()
Select Case Application.Caller
Case "ImportBttn"
`1st tab
Me.MultiPage1.Value = 0
Case "ProtctBttn"
`3rd tab
Me.MultiPage1.Value = 2
End Select
End Sub
like image 27
brettdj Avatar answered Nov 15 '22 07:11

brettdj