ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Selecting Certain Userform Controls (https://www.excelbanter.com/excel-programming/426457-selecting-certain-userform-controls.html)

JeremyJ

Selecting Certain Userform Controls
 
Is it possible to loop through only the controls on a specific page of a
multipage?

OssieMac

Selecting Certain Userform Controls
 
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

--
Regards,

OssieMac


"JeremyJ" wrote:

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


Rick Rothstein

Selecting Certain Userform Controls
 
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

--
Rick (MVP - Excel)


"JeremyJ" wrote in message
...
Is it possible to loop through only the controls on a specific page of a
multipage?




All times are GMT +1. The time now is 02:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com