Selecting Certain Userform Controls

J

JeremyJ

Is it possible to loop through only the controls on a specific page of a
multipage?
 
O

OssieMac

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
 
R

Rick Rothstein

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top