Adding Multipage Dynamically

angsuman

New Member
Joined
Aug 19, 2015
Messages
30
Hello All,


I am stuck while adding multipage dynamically to a blank userform.


First I tried following code:

Code:
Dim HolCalMulPg      As MultiPage


Set HolCalMulPg = Me.Controls.Add("Forms.MultiPage.1")



Above code added a multi page with two pages. Now I changed the code to below:

Code:
Dim HolCalMulPg        As MultiPage
Dim NumPages     	As Long


NumPages = UBound(CostCollectorArray, 1)   <------- CostCollectorArray is array with two rows and 3 columns. Column 1 of each row 		 
                                                                               contains name of each page of the multipage


For i = 1 To NumPages
  Set HolCalMulPg = Me.Controls.Add("Forms.MultiPage.1")
Next


Above code still adds two pages to multipage. In above example NumPages = 2 and result is ok but I tried changing the value of NumPages to 3 but number of pages added is 2 which seems default. How do I ensure that number of pages added is same as the the value in NumPages.

Thanks
Angsuman
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Code:
Dim PageCount As Long

PageCount = 4

Set HolCalMulPg =Me.Controls.Add("Forms.Multipage.1")

With HolCalMulPg
    Do Until .Pages.Count <= PageCount
        .Pages.Remove 0
    Loop
    Do Until .Pages.Count >= PageCount
        .Pages.Add
    Loop
End With
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,814
Messages
6,181,124
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top