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.
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.
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.
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.
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
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With