Counting CheckBoxes on a Userform

E

ExcelMonkey

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
 
J

Jim May

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top