View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
ExcelMonkey ExcelMonkey is offline
external usenet poster
 
Posts: 553
Default Loop through pages in multipage control

I have a line of code which hides pages in a multipage control:

If pg.Index < SomeVariable Then
pg.Visible = False
End If

I now want to replace SomeVariable with an ArrayOfVariables. There will be
two variables in the array - say 1 and 2. However the code below does not
work as the page which survives the first loop gets axed during the second
loop. What do I need to do to preserve the page that is retained in earlier
iterations of the loop. I almost need to pass all true tests in another
array.

Private Function PageRetain()
Dim X As Integer
For X = 0 To UBound(ListItemArray) ' this equals 1
For Each pg In UserForm1.MultiPage1.Pages
If pg.Index < ListItemArray(X) - 1 Then ' this array has 2 elements:
1, 2
pg.Visible = False
End If
Next
Next
End Function