L Kadue
L Kadue

Reputation: 83

VBA: userform multipage template

I'm making a Userform that would allow the user to changes the bounds on several charts at once. I figured out how everything should look on the first multipage, and now I'm wondering if there's any way I could add 11 pages at once to look just like the first page. My userform appears below.

Userform

I am still in the design phase for this. If there's a way to do this in the design that would be great. If there's a way to do in the Initialize sub that would also be great.

Upvotes: 0

Views: 1954

Answers (1)

PatricK
PatricK

Reputation: 6433

Based on your intended usage, you should be using a TabStrip instead of MultiPage being most controls within are the same layout (same amount of controls). MultiPage is intended for categorizing data with different controls on each page.

Consider this simple userform to demostrate the benefit of using TabStrip here:

UserForm Design
The left side square is a Picture holder I have not put codes for.

With below code to handle tab changes, certain elements in the userform will change when a different Tab is clicked.

Option Explicit

Private Sub TabStrip1_Change()
    Dim TabX As String
    With Me.TabStrip1
        TabX = .Tabs(.Value).Caption
        Debug.Print "ActiveTab:", TabX
    End With
    Me.Frame1.Caption = "Maximum Bounds (" & TabX & ")"
    Me.Frame2.Caption = "Minimum Bounds (" & TabX & ")"
    Me.TextBox1.Value = "TextBox2 for " & TabX ' Forgot to change this Value to TextBox1 before the screenshot...
    Me.TextBox2.Value = "TextBox2 for " & TabX
End Sub
  1. Upon launching the userform (without setting UserForm_Initialize):
    FirstLaunch
  2. Tab2 clicked:
    Tab2Click
  3. Tab1 clicked:
    Tab2Click

Upvotes: 2

Related Questions