Excel VBA UserForm Example With MultiPage Control (Full Guide + Sample Code)

Excel MultiPage Control Creating a professional and user-friendly interface in Excel becomes much easier when you use VBA UserForms. They allow you to design custom forms, collect user input, display data, and build small applications inside Excel.
In this guide, we will walk through a complete Excel UserForm example that includes a MultiPage control, menu interface, buttons, and sample VBA code.

⭐ What Is an Excel UserForm?

A UserForm in Excel VBA is a graphical interface that allows users to enter, view, and manage data without interacting directly with worksheet cells.
It can contain controls such as:
➯ TextBoxes
➯ ComboBoxes
➯ ListBoxes
➯ Buttons
➯ Labels
➯ CheckBoxes
➯ MultiPage (Tabs)
UserForms are particularly useful when building internal tools, automation panels, and data entry interfaces.

⭐ Why Use a MultiPage Control?

A MultiPage control helps you divide the form into different sections (tabs). This improves organization and makes the form cleaner and easier to navigate.

For example, you can create pages such as:
Page 1 → Personal Information
Page 2 → Product Details
Page 3 → Settings
Page 4 → About / Help
MultiPage is essential when your form contains many fields.

⭐ How to Insert a UserForm and MultiPage Control?

1. Open the VBA Editor
  1.Press ALT + F11
  2.Go to Insert → UserForm

2. Add the MultiPage Control
  1.From the Toolbox, click MultiPage
  2.Draw it on your UserForm
  3.Rename pages via the Properties section

3. Add Buttons, TextBoxes, or Controls
For example:
  · Add a Menu Page
  · Add navigation buttons
  · Insert a “Close” button

In our template,the userform multipage control contains two page control. 
At Page 1 (named as Page3 in our template), personnel informations (name,address,city,phone,birthdate,birthplace etc.) can be added,deleted,changed with listbox,textbox,combobox controls. 
At Page 2 (Page4 in our template), city names are added to the Data2 worksheet using textbox, listbox and buttons on Page 2. The added city names are filled in the combobox on Page 1.

The choosed controls such as textbox, button, label from Toolbox can be added to the selected page tab of Multipage control. In VBA, the following codes are used to select the page tabs of Multipage:
To select the first page :      MultiPage2.Value = 0    (In our template , Multipage control is named as MultiPage2)
✓ To select the second page :     MultiPage2.Value = 1
✓ Or to add a vertical scrollbar to the first page :     MultiPage2.Pages(0).ScrollBars = fmScrollBarsVertical

The content of Multipage control’s first page tab :
The following operations can be performed with the VBA controls on Page 1 :
☑ Adding new record
☑ Deleting record
☑ Updating record
☑ Label to see total data
☑ Navigating between items of listbox with spin buttons (down/up)
☑ Assigning sort numbers for each record (when an item is deleted from listbox, the sequence numbers are set again.)

The content of Multipage control’s second page tab :
☑ With the userform elements in Page 2, cities are entered in column A of the Data2 worksheet.To combobox on Page 1, city names are filled in as unique and sorted items.

📌 Sample VBA Code for MultiPage UserForm

To List Columns B (Surname) and C (First Name) of "Data" Sheet on ListBox1 : 
Dim sds As Long
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "74;78"
sds = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
ListBox1.List = Sheets("Data").Range("B2:C" & sds).Value
Populate Text Boxes and Combobox Based on ListBox Selected Item : 
Private Sub ListBox1_Click()
Dim Bulunan_Satir_No As Long
Bulunan_Satir_No = ListBox1.ListIndex + 2
    
 TextBox1.Text = Sheets("Data").Range("B" & Bulunan_Satir_No).Value
 TextBox2.Text = Sheets("Data").Range("C" & Bulunan_Satir_No).Value
 TextBox3.Text = Sheets("Data").Range("D" & Bulunan_Satir_No).Value
 ComboBox1.Value = Sheets("Data").Range("E" & Bulunan_Satir_No).Value
 TextBox5.Text = Sheets("Data").Range("F" & Bulunan_Satir_No).Value
 TextBox6.Text = Sheets("Data").Range("G" & Bulunan_Satir_No).Value
 TextBox7.Text = Sheets("Data").Range("H" & Bulunan_Satir_No).Value
 TextBox8.Text = Sheets("Data").Range("I" & Bulunan_Satir_No).Value
 TextBox9.Text = Sheets("Data").Range("J" & Bulunan_Satir_No).Value
 TextBox10.Text = Sheets("Data").Range("K" & Bulunan_Satir_No).Value
 TextBox11.Text = Sheets("Data").Range("L" & Bulunan_Satir_No).Value
 TextBox12.Text = Sheets("Data").Range("M" & Bulunan_Satir_No).Value
 TextBox12.Text = VBA.Format(TextBox12, "dd.mm.yyyy")
End Sub
Saving Values Entered into the TextBox to the Sheet and Listing It on the ListBox. : 
Private Sub CommandButton1_Click()
Dim Son_Dolu_Satir, Bos_Satir As Long, ver As Long
Sheets("Data").Activate
If Me.TextBox1.Value = "" Or Me.TextBox2.Value = "" Or Me.TextBox3.Value = "" Or Me.TextBox5.Value = "" Then
Call MsgBox("The fields are not complete", vbInformation, "Edit Contact")
Exit Sub
End If
'If the entered value has been saved before, a warning is given with a message box
and it cannot be saved again.
For ver = 2 To Cells(Rows.Count, "B").End(xlUp).Row
  If Cells(ver, "B") = TextBox1 And Cells(ver, "B").Offset(0, 1) = TextBox2 Then
  MsgBox "This name is already registered !", vbInformation, ""
  TextBox2.SetFocus
  Exit Sub
  End If
Next

Son_Dolu_Satir = Sheets("Data").Cells(Rows.Count, "A").End(xlUp).Row
Bos_Satir = Son_Dolu_Satir + 1
                
Sheets("Data").Range("A" & Bos_Satir).Value = Application.WorksheetFunction.Max(Sheets("Data").Range("A:A")) + 1
Sheets("Data").Range("B" & Bos_Satir).Value = TextBox1.Text
Sheets("Data").Range("C" & Bos_Satir).Value = TextBox2.Text
Sheets("Data").Range("D" & Bos_Satir).Value = TextBox3.Text
Sheets("Data").Range("E" & Bos_Satir).Value = ComboBox1.Value
Sheets("Data").Range("F" & Bos_Satir).Value = TextBox5.Text
Sheets("Data").Range("G" & Bos_Satir).Value = TextBox6.Text
Sheets("Data").Range("H" & Bos_Satir).Value = TextBox7.Text
Sheets("Data").Range("I" & Bos_Satir).Value = TextBox8.Text
Sheets("Data").Range("J" & Bos_Satir).Value = TextBox9.Text
Sheets("Data").Range("K" & Bos_Satir).Value = TextBox10.Text
Sheets("Data").Range("L" & Bos_Satir).Value = TextBox11.Text
Sheets("Data").Range("M" & Bos_Satir).Value = TextBox12.Text
Sheets("Data").Range("M" & Bos_Satir).HorizontalAlignment = xlRight
                
Sheets("Data").Select
ListBox1.Clear
      Call refresh  'With the called procedure, the items in ListBox1 are relisted and
                     the newly added record is displayed immediately.
Label14.Caption = ListBox1.ListCount
End Sub

Sub refresh()
Dim sds As Long
ListBox1.ColumnCount = 2
ListBox1.ColumnWidths = "74;78"
sds = Sheets("Data").Cells(Rows.Count, "B").End(xlUp).Row
ListBox1.List = Sheets("Data").Range("B2:C" & sds).Value
End Sub
Activating The Cell on Sheet According To the Item Selected in ListBox2 : 
Private Sub ListBox2_Click()
Dim lastrow As Long

Sheets("Data2").Activate
lastrow = Sheets("Data2").Cells(Rows.Count, "A").End(xlUp).Row
Sheets("Data2").Range("A2:A" & lastrow).Find(What:=ListBox2.Value, LookIn:=xlValues, LookAt:=xlWhole).Activate
TextBox13.Value = ActiveCell

End Sub
To Populate Unique and Sorted Values to ComboBox : 
Dim x As Long, a, b As Long, c As Variant
       
For x = 2 To Sheets("Data2").Cells(Rows.Count, "A").End(xlUp).Row
If WorksheetFunction.CountIf(Sheets("Data2").Range("A2:A" & x), _
  Sheets("Data2").Cells(x, 1)) = 1 Then
  ComboBox1.AddItem Sheets("Data2").Cells(x, 1).Value
End If
Next
     
For a = 0 To ComboBox1.ListCount - 1
  For b = a To ComboBox1.ListCount - 1
    If UCase(ComboBox1.List(b)) < UCase(ComboBox1.List(a)) Then
c = ComboBox1.List(a)
    ComboBox1.List(a) = ComboBox1.List(b)
    ComboBox1.List(b) = c
       End If
   Next
 Next


⭐ We also added a menu bar to the userform using a class(object) and listed the menu items as labels on a frame control. Items of this menu :
☑ New
☑ Open
☑ Save
☑ Save As
☑ Print Preview
☑ Print
☑ Close

excel userform multipage userform menu bar

VBA codes of menu bar items : 
Private Sub Label19_Click()            'New menu
Workbooks.Add
End Sub
Private Sub Label20_Click()            'Open menu
Application.Dialogs(xlDialogOpen).Show
End Sub
Private Sub Label21_Click()            'Save menu
ActiveWorkbook.Save
End Sub
Private Sub Label22_Click()             'Save as menu
Application.Dialogs(xlDialogSaveAs).Show
End Sub
Private Sub Label23_Click()             'Print preview menu 
UserForm1.Hide
ActiveSheet.PrintPreview
UserForm1.Show
End Sub
Private Sub Label24_Click()              'Print menu
ActiveSheet.PrintOut
End Sub
Private Sub Label25_Click()              'Close userform
UserForm1.Hide
End Sub


1. What is a MultiPage control in an Excel VBA UserForm? +
A MultiPage control allows you to split a UserForm into multiple logical pages. In this example, the MultiPage contains pages such as Personnel Form and Add / Delete City, helping to separate data entry tasks from management operations while keeping the interface clean and user-friendly.
2. How do I add a MultiPage control to a UserForm? +
Open the VBA editor, select MultiPage from the Toolbox and add it to your UserForm. You can rename each tab and add buttons, labels or other controls inside each page.
3. Can I switch between MultiPage tabs using VBA code? +
Yes. For example, MultiPage1.Value = 0 will activate the New tab. You can switch to other tabs using index numbers like 1, 2, or 3.
4. Can I add new pages to a MultiPage control in Excel VBA? +
Yes, you can easily add new pages to a MultiPage control. In the VBA editor, simply right-click on the MultiPage and choose New Page. Each new page can then be customized with its own buttons, labels, and VBA code, making it ideal for extending your menu structure or adding new features later.
5. Can I customize the visual look of a MultiPage control? +
Yes. You can change fonts, colors, and tab captions. For a more modern look, you can add icons, images, or framed panels inside each page.
6. Can I create a custom Menu Bar in a UserForm using a VBA Class and Frame control? +
Yes. A common and effective approach is to place a Frame control at the top of the UserForm and use it as a container for a custom Menu Bar. By combining the Frame with a VBA Class (Object), you can create menu items such as New, Open, Save, Save As, Print Preview, Print, and Close in a clean and reusable structure.
👍 Helpful 👎 Not helpful
0 people found this helpful
excel userform multipage new menu bar

Post a Comment

Previous Post Next Post