Using VBA to add tabs to a multipage useform in excel

11,684

Solution 1

The Tabs in a MultiPage1 are called Pages and you can add them using

MultiPage1.Pages.Add

You can use the above code in a loop to add pages. Please refer to Excel's inbuilt help for more details

Edit:

Just saw the 2nd part of the question. To delete, say the 1st page use this

MultiPage1.Pages.Remove (0)

Solution 2

You can add/remove them dymanically to the form permanently with

Sub Test()
Dim vbComp As Object
Dim objCntrl As Control
Set vbComp = ThisWorkbook.VBProject.VBComponents("UserForm1")
Set objCntrl = vbComp.Designer.Controls("MultiPage1")
'add page
objCntrl.Pages.Add
'remove page
objCntrl.Pages.Remove (1)
End Sub
Share:
11,684
Ehudz
Author by

Ehudz

Updated on June 27, 2022

Comments

  • Ehudz
    Ehudz almost 2 years

    I need to find the VBA code to add x number of tabs to a multipage in a userform in excel. I can manually add tabs if I use the visual basic editor, but I want to be able to dynamically add/delete tabs using VBA during runtime.

    Thanks