ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   For Each Ctl In Me.Controls (https://www.excelbanter.com/excel-programming/403370-each-ctl-me-controls.html)

LongBeachGuy

For Each Ctl In Me.Controls
 

Merry Christmas and a Happy New Year.


I want to

#1. Identify controls in my userform1 as checkbox

#2.Find out how many and which checkboxes are checked

#3. Run another process using the selected enabled checkboxes.

Me.Controls does not work.

I tried:

Dim ctrl As MSForms.Control
Dim cbox As MSForms.CheckBox

For Each ctrl In Me.Controls

If TypeOf ctrl Is MSForms.CheckBox Then
Set cbox = ctrl
msgbox cbox.Name
End If

Next



My computer stops at the first line: :

"For Each ctrl In Me.Controls"

and gives:

"Run-time error '438'"
"Object doesn't support this object or method

Please help me,

Jose

Bob Phillips

For Each Ctl In Me.Controls
 
Works fine for me. You have that code in the form?


--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"LongBeachGuy" wrote in message
...

Merry Christmas and a Happy New Year.


I want to

#1. Identify controls in my userform1 as checkbox

#2.Find out how many and which checkboxes are checked

#3. Run another process using the selected enabled checkboxes.

Me.Controls does not work.

I tried:

Dim ctrl As MSForms.Control
Dim cbox As MSForms.CheckBox

For Each ctrl In Me.Controls

If TypeOf ctrl Is MSForms.CheckBox Then
Set cbox = ctrl
msgbox cbox.Name
End If

Next



My computer stops at the first line: :

"For Each ctrl In Me.Controls"

and gives:

"Run-time error '438'"
"Object doesn't support this object or method

Please help me,

Jose





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

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