Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default Looping Thru Objects in UserForms

Need a little help trying to loop through objects on a form. I have say,
10 checkboxes and a ComboBox on a UserForm and based on ComboBox selection
(1-10) I want to make visible = false any chekbox over that value. I can
do this individually but would like to loop through each one as I have many
sets. The Checkbox Names are "C1" thru "C10". I was hoping to
loop/increment throught the Number portion "C x". I can do this looping in
Cells, but not in UserForms. I tried the "Evaluate" but could never get it
correct. I do this in javascript using eval but can't figure this out in
VB. Thanks, Rob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 860
Default Looping Thru Objects in UserForms

Hi RobC,

Something like this should work:

Private Sub cboTest_Change()
Dim ctl As Control

On Error Resume Next
For Each ctl In Controls
If TypeOf ctl Is MSForms.CheckBox Then
ctl.Visible = (CInt(Mid$(ctl.Name, 2)) _
<= CInt(cboTest.Text))
End If
Next ctl
On Error GoTo 0
End Sub

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]


RobC wrote:
Need a little help trying to loop through objects on a form. I have
say, 10 checkboxes and a ComboBox on a UserForm and based on
ComboBox selection (1-10) I want to make visible = false any chekbox
over that value. I can do this individually but would like to loop
through each one as I have many sets. The Checkbox Names are "C1"
thru "C10". I was hoping to loop/increment throught the Number
portion "C x". I can do this looping in Cells, but not in UserForms.
I tried the "Evaluate" but could never get it correct. I do this in
javascript using eval but can't figure this out in VB. Thanks, Rob

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Looping Thru Objects in UserForms

Dim ctl As msforms.Control

For Each ctl In Me.Controls
If Left(ctl.Name, 8) = "CheckBox" Then
If Val(Right(ctl.Name, 2)) 9 Then
ctl.Value = False
End If
End If
Next ctl


--

HTH

RP
(remove nothere from the email address if mailing direct)


"RobC" wrote in message
om...
Need a little help trying to loop through objects on a form. I have say,
10 checkboxes and a ComboBox on a UserForm and based on ComboBox

selection
(1-10) I want to make visible = false any chekbox over that value. I can
do this individually but would like to loop through each one as I have

many
sets. The Checkbox Names are "C1" thru "C10". I was hoping to
loop/increment throught the Number portion "C x". I can do this looping

in
Cells, but not in UserForms. I tried the "Evaluate" but could never get

it
correct. I do this in javascript using eval but can't figure this out in
VB. Thanks, Rob



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
Beginer to UserForms question on assigning properties to objects [email protected] Excel Discussion (Misc queries) 3 July 27th 07 01:45 PM
Dynamically Assign Objects to Form Objects. The Vision Thing Excel Programming 2 December 11th 04 04:02 PM
Unable to remove Sheet objects in the Microsoft Excel Objects Adrian[_7_] Excel Programming 1 August 26th 04 10:49 PM
looping and objects Rune[_2_] Excel Programming 6 July 10th 04 05:31 PM
userforms Jo[_4_] Excel Programming 2 September 17th 03 10:35 PM


All times are GMT +1. The time now is 07:56 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"