Count CheckBoxes in UserForm

  • Thread starter Thread starter Lenny_821
  • Start date Start date
L

Lenny_821

Hi All,

I've got a few CheckBoxes in a UserForm. How can I count the
CheckBoxes in VBA??

Please help:)

Lenny
 
Lenny,

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
 
Dim ctrl as MsForms.Control, cnt as Long
cnt = 0
for each ctrl in Userform1.Controls
if typeof ctrl is msforms.checkbox then
cnt = cnt + 1
end if
Next
msgbox cnt
 
Back
Top