ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Counting CheckBoxes (https://www.excelbanter.com/excel-programming/335430-counting-checkboxes.html)

scantor145[_17_]

Counting CheckBoxes
 

Excel 2003 w/Visual Basic 6.3

I have a form with many check boxes. I want to know how man
checkboxes the user has selected.

All names of checkboxes start with "chk".

I tried the following :


Code
-------------------
For Each Ctl In frmReagInv.Controls
If Left(Ctl.Name, 3) = "chk" And Ctl.Value = True Then
NumChem = NumChem + 1
End If
Next Ct
-------------------


but get the following message:

"Object doesn't support this property or method"

when


Code
-------------------
If Left(Ctl.Name, 3) = "chk" And Ctl.Value = True The
-------------------


is encountered.

Anything wrong with Ctl.Value?

Any other suggestions

--
scantor14
-----------------------------------------------------------------------
scantor145's Profile: http://www.excelforum.com/member.php...fo&userid=1476
View this thread: http://www.excelforum.com/showthread.php?threadid=38987


Tom Ogilvy

Counting CheckBoxes
 
For Each Ctl In frmReagInv.Controls
if Typeof Ctl is MSForms.checkbox then
If Ctl.Value = True Then
NumChem = NumChem + 1
End If
End if
Next Ctl

--
Regards,
Tom Ogilvy


"scantor145" wrote
in message ...

Excel 2003 w/Visual Basic 6.3

I have a form with many check boxes. I want to know how many
checkboxes the user has selected.

All names of checkboxes start with "chk".

I tried the following :


Code:
--------------------
For Each Ctl In frmReagInv.Controls
If Left(Ctl.Name, 3) = "chk" And Ctl.Value = True Then
NumChem = NumChem + 1
End If
Next Ctl
--------------------


but get the following message:

"Object doesn't support this property or method"

when


Code:
--------------------
If Left(Ctl.Name, 3) = "chk" And Ctl.Value = True Then
--------------------


is encountered.

Anything wrong with Ctl.Value?

Any other suggestions.


--
scantor145
------------------------------------------------------------------------
scantor145's Profile:

http://www.excelforum.com/member.php...o&userid=14766
View this thread: http://www.excelforum.com/showthread...hreadid=389871





All times are GMT +1. The time now is 07:29 PM.

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