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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,222,022
Messages
6,163,451
Members
451,837
Latest member
gmc

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