Multipage Control - problem with removing pages

morse101

New Member
Joined
Jul 2, 2007
Messages
3
Hi,

I am using Excel 2003 and am trying to get the hang of manipulating the Multipage Control at run-time. Adding extra pages as and when required poses no problem but Removing them does.

Typical example for a Multipage Control with 8 pages from which I would like to remove pages 3, 5 and 7 with the names XXX3, XXX5 and XXX7:

Sub RemovePages ()
Dim intSheetCount As Integer
Dim strCaption As String

For intSheetCount = 3 To 7 Step 2
strCaption = "Page" & intSheetCount
UserForm1.MultiPage1.Pages.Remove (strCaption)
Next intSheetCount

End Sub

Every time this routine is run it produces a Run - time error 5:
invalid procedure call or argument. As far as I can see the code appears to be OK ***except*** that I cannot get rid of the space immediately after the 'Remove' in

UserForm1.MultiPage1.Pages.Remove (strCaption)

I suspect that might be the problem but otherwise I am completely at sea. So any and all help will be gratefully received.

many thanks

M.
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Forum statistics

Threads
1,181,416
Messages
5,929,790
Members
436,694
Latest member
dpatete

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
Top