Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
"For Each" Statement error...
Hi I'm having a little trouble with "For each"... I want to use this statement to know the number of checkboxes in my form, for example... It's kind of: dim check as checkbox For each check in my_form i=i+1 Next check But it doesn't work... I don't know if I'm using the statement correctly... -- pmguerra ------------------------------------------------------------------------ pmguerra's Profile: http://www.excelforum.com/member.php...o&userid=14986 View this thread: http://www.excelforum.com/showthread...hreadid=560898 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
"For Each" Statement error...
Dim ctl As MSForms.Control
Dim i as long For Each ctl In UserForm1.Controls If TypeName(ctl) = "CheckBox" Then i = i + 1 End If Next msgbox i & " checkboxes" RBS "pmguerra" wrote in message ... Hi I'm having a little trouble with "For each"... I want to use this statement to know the number of checkboxes in my form, for example... It's kind of: dim check as checkbox For each check in my_form i=i+1 Next check But it doesn't work... I don't know if I'm using the statement correctly... -- pmguerra ------------------------------------------------------------------------ pmguerra's Profile: http://www.excelforum.com/member.php...o&userid=14986 View this thread: http://www.excelforum.com/showthread...hreadid=560898 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
"For Each" Statement error...
This is how to do it
Dim ctl As Control For Each ctl In Me.Controls If TypeName(ctl) = "CheckBox" Then MsgBox ctl.Caption End If Next ctl -- HTH Bob Phillips (replace somewhere in email address with gmail if mailing direct) "pmguerra" wrote in message ... Hi I'm having a little trouble with "For each"... I want to use this statement to know the number of checkboxes in my form, for example... It's kind of: dim check as checkbox For each check in my_form i=i+1 Next check But it doesn't work... I don't know if I'm using the statement correctly... -- pmguerra ------------------------------------------------------------------------ pmguerra's Profile: http://www.excelforum.com/member.php...o&userid=14986 View this thread: http://www.excelforum.com/showthread...hreadid=560898 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
"For Each" Statement error...
It's a little more complicated than that... try doing it this way.
Dim check As Control 'All types of controls Dim i As Integer For Each check In UserForm1.Controls 'Loop through each control in userform1 controls If TypeName(check) = "CheckBox" Then 'Because we are going through all the controls we need to filter out just the "CheckBoxes" i = i + 1 End If Next MsgBox i HTH Die_Another_Day pmguerra wrote: Hi I'm having a little trouble with "For each"... I want to use this statement to know the number of checkboxes in my form, for example... It's kind of: dim check as checkbox For each check in my_form i=i+1 Next check But it doesn't work... I don't know if I'm using the statement correctly... -- pmguerra ------------------------------------------------------------------------ pmguerra's Profile: http://www.excelforum.com/member.php...o&userid=14986 View this thread: http://www.excelforum.com/showthread...hreadid=560898 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
"For Each" Statement error...
One more...
Dim ctrl As Control For Each ctrl In Me.Controls If TypeOf ctrl Is MSForms.CheckBox Then ctrl.Object.Value = True End If Next ctrl pmguerra wrote: Hi I'm having a little trouble with "For each"... I want to use this statement to know the number of checkboxes in my form, for example... It's kind of: dim check as checkbox For each check in my_form i=i+1 Next check But it doesn't work... I don't know if I'm using the statement correctly... -- pmguerra ------------------------------------------------------------------------ pmguerra's Profile: http://www.excelforum.com/member.php...o&userid=14986 View this thread: http://www.excelforum.com/showthread...hreadid=560898 -- Dave Peterson |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
"For Each" Statement error...
Thank you very much!!! : -- pmguerr ----------------------------------------------------------------------- pmguerra's Profile: http://www.excelforum.com/member.php...fo&userid=1498 View this thread: http://www.excelforum.com/showthread.php?threadid=56089 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
embedding "ISERROR" function into an "IF" statement | Excel Worksheet Functions | |||
Shortcut key for "Paste Options" and "Error Checking" buttons? | Excel Discussion (Misc queries) | |||
What is Error "Method "Paste" of object "_Worksheet" failed? | Excel Programming | |||
Getting "compile error" "method or data member not found" on reinstall | Excel Programming | |||
Need help in excel with "Statement invalid outside Type block. " error | Excel Programming |