Hi all thanks for taking the time to look at this and any advice given.
I have a userform with 2 multipages (2&3) depending on criteria pages are dynamically added to these along with page names.
What I am trying to do is check to see if pages have been added and if they have then remove these pages leaving only the original page page1 .
this is to reset the multipages when criteria changed.
This is the code I am trying to get working.
Dim PGNAME As String
Dim I As Integer
Dim pgno As String
pgno = MultiPage2.Pages.Count
If pgno >= 0 Then
For I = 0 To MultiPage2.Count + 1
PGNAME = MultiPage2.Pages(I).Name This is where I get a runtime error 5 invalid procedure
If PGNAME = ("PAGE1") Then
GoTo 1
Else
MultiPage2.Pages.Remove (PGNAME)
End If
1:
Next I
For I = 0 To MultiPage3.Count + 1
PGNAME = MultiPage3.Pages(I).Name
If PGNAME = ("PAGE1") Then
GoTo 2
Else
MultiPage3.Pages.Remove (PGNAME)
End If
2:
Next I
Else
I have a userform with 2 multipages (2&3) depending on criteria pages are dynamically added to these along with page names.
What I am trying to do is check to see if pages have been added and if they have then remove these pages leaving only the original page page1 .
this is to reset the multipages when criteria changed.
This is the code I am trying to get working.
Dim PGNAME As String
Dim I As Integer
Dim pgno As String
pgno = MultiPage2.Pages.Count
If pgno >= 0 Then
For I = 0 To MultiPage2.Count + 1
PGNAME = MultiPage2.Pages(I).Name This is where I get a runtime error 5 invalid procedure
If PGNAME = ("PAGE1") Then
GoTo 1
Else
MultiPage2.Pages.Remove (PGNAME)
End If
1:
Next I
For I = 0 To MultiPage3.Count + 1
PGNAME = MultiPage3.Pages(I).Name
If PGNAME = ("PAGE1") Then
GoTo 2
Else
MultiPage3.Pages.Remove (PGNAME)
End If
2:
Next I
Else