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.
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.