Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 151
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Looping through listbox controls Vince Excel Programming 11 April 12th 05 04:40 PM
Looping through controls on form Robbyn Excel Programming 2 March 15th 05 02:37 PM
looping through userform controls JulieD Excel Programming 2 August 14th 04 02:13 PM
Looping through multiple controls rci Excel Programming 2 March 4th 04 08:43 PM
Looping thru custom controls papou[_6_] Excel Programming 2 July 23rd 03 04:14 PM


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"