Selecting Certain Userform Controls

  • Thread starter Thread starter JeremyJ
  • Start date Start date
Hi Jeremy,

The following example loops through the pages of a Multipage and loops
through the controls on each page.

Note that the page index start at zero.

Sub MultiPageLoop()

Dim i As Integer
Dim objCtrl As Object

With UserForm1
For i = 0 To .MultiPage1.Count - 1
With .MultiPage1.Pages(i)
For Each objCtrl In .Controls
MsgBox objCtrl.Name
Next objCtrl
End With
Next i
End With

End Sub
 
Yes, you can do that. In the code that follows, just replace the Debug.Print
statement with the code you want to execute for each of the controls on the
specified page...

Dim C As Control
Dim PageToLoopThru As Long
' Remember, pages are numbered starting at zero, so this
' line will select the THIRD tab on the MultiPage for the loop
PageToLoopThru = 2
For Each C In MultiPage1.Pages(PageToLoopThru).Controls
Debug.Print C.Name
Next
 
Back
Top