Reputation: 21
I'm confident this is going to be a very easy answer for anyone with VBA knowledge (which I don't have). I have a form built for Excel in VBA. It's a multitab form and I want to have the form consistently open on the first tab when the "Open Form X" button is clicked in Excel. Let's call the form "Form1" and the tab "IDTab"
I have tried the following code but neither has worked:
Private Sub GetFormButton_Click()
Form1.Show With MultiPage1 Value = 0
End Sub
AND
Private Sub BackToExclu_Click()
With MultiPage1
.Value = (.Value - 1) Mod (.Pages.Count)
End With
End Sub
Upvotes: 1
Views: 5884
Reputation: 152
Open y
In the programcode for the form enter the code below:
Private Sub UserForm_Activate()
MultiPage1.Pages("IDTab").Enabled = True
End Sub
Mind you: MultiPage1 might be called differently in your form. MultiPage1 is the default name of the container holding the tabbed pages in my excel workbook. In the properety window you can find the actual name of that container.
Upvotes: 0
Reputation: 27259
You were very close, actually :)
If you place the code into the Initiliaze Event
within the userform itself, it will always display the first page of the multi-page control any time the form is loaded.
Private Sub UserForm_Initialize()
Me.MultiPage1.Value = 0
End Sub
To place this code into the UserForm Module, right click on the UserForm
object in the VBE and click View Code
.
Then your button click code would just be:
Private Sub GetFormButton_Click()
Form1.Show
End Sub
Upvotes: 3