2

I have a UserForm in Excel with MultiPage object. I need to add more tab pages into the MultiPage object dynamically, by copying and pasting one of the existing tab pages. Any help would be appreciated.

Thank you

Doug Glancy
  • 27,214
  • 6
  • 67
  • 115
Fred
  • 378
  • 1
  • 10
  • 26

1 Answers1

2

You can do this by using this piece of code

Option Explicit

Private Sub CommandButton1_Click()

    '~~> Change 1 to the respective page index which you want to replicate
    MultiPage1.Pages(1).Controls.Copy

    '~~> Add a New page
    MultiPage1.Pages.Add

    '~~> Paste the copied controls
    MultiPage1.Pages(MultiPage1.Pages.Count - 1).Paste

End Sub

SNAPSHOT

enter image description here

Siddharth Rout
  • 147,039
  • 17
  • 206
  • 250
  • Hi Siddharth,Thank you for your response. I just did it and it worked fine in a sample code, but when I integrated it with my code, Excel restarts at the MultiPage1.Pages.Add line. I think it is because I have a lot of controls in each existing tab page. I'm trying to use TabStrip instead of MultiPage. This way I can use a single set of controls for all the tab pages. – Fred Apr 19 '12 at 17:05