ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting CheckBoxes on a Userform (https://www.excelbanter.com/excel-programming/322548-counting-checkboxes-userform.html)

ExcelMonkey[_190_]

Counting CheckBoxes on a Userform
 
I have a userform. It is increasing in complexity with
various controls in it. It has:

1 Text Box
6 checkboxes
2 buttons


Is there a way to count the number of check boxes the form
has? I know that I can count the number of total controls
by :

NumberofControls = Userform1.Controls.Count

This gives me a value of 9 which includes the text box and
the two buttons. How do I isolate the checkboxes or any
other control of my liking.


Thanks

Jim May

Counting CheckBoxes on a Userform
 
Off Google:

Try something like the following:

Dim Ctrl As MSForms.Control
Dim N As Long
For Each Ctrl In UserForm1.Controls
If TypeOf Ctrl Is MSForms.CheckBox Then
N = N + 1
End If
Next Ctrl


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"ExcelMonkey" wrote in message
...
I have a userform. It is increasing in complexity with
various controls in it. It has:

1 Text Box
6 checkboxes
2 buttons


Is there a way to count the number of check boxes the form
has? I know that I can count the number of total controls
by :

NumberofControls = Userform1.Controls.Count

This gives me a value of 9 which includes the text box and
the two buttons. How do I isolate the checkboxes or any
other control of my liking.


Thanks





All times are GMT +1. The time now is 05:21 PM.

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