![]() |
Looping through controls
Hi
How do you loop through the labels on a userform and ignore other controls such as commandbuttons? When I try and do this using the code below, I find that all the controls are included in the loop. Sub userform1_activate() For each label in userform1.controls label.caption = "test" next End Sub Many thanks in advance L |
Looping through controls
Sub userform1_activate()
For each ctrl in userform1.controls if typeof ctrl is MSForms.Label then ctrl.caption = "test" end if next End Sub -- Regards, Tom Ogilvy "Libby" wrote in message ... Hi How do you loop through the labels on a userform and ignore other controls such as commandbuttons? When I try and do this using the code below, I find that all the controls are included in the loop. Sub userform1_activate() For each label in userform1.controls label.caption = "test" next End Sub Many thanks in advance L |
All times are GMT +1. The time now is 01:14 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com