ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Count Checkboxes. (https://www.excelbanter.com/excel-programming/298579-re-count-checkboxes.html)

Tom Ogilvy

Count Checkboxes.
 

for checkboxes from the control toolbox toolbar on a worksheet

Dim obj as OleObject
Dim cnt as Long
Dim chkbx as Msforms.Checkbox
For each obj in Activesheet.OleObject
if typeof obj.Object is MsForms.Checkbox then
set chkbx = obj.Object
if chkbx = True then
cnt = cnt + 1
end if
end if
Next

For forms controls on a worksheet

Dim chkbx as Checkbox
Dim cnt as Long
for each chkbx in Activesheet.Checkboxes
if chkbx.Value = xlOn then
cnt = cnt + 1
end if
Next

--
Regards,
Tom Ogilvy


"Steven" wrote in message
...
Looking for a way to count the number of checkboxes with a check in them.

Thanks for your time,
Steven




Bob Phillips[_6_]

Count Checkboxes.
 
Another way is to link each checkbox to a cell, say Z1, then Z2, then Z3,
etc, and use COUNTIF

=COUNTIF(Z1:Z10,TRUE)

This works for both forms and control toolbox checkboxes.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Tom Ogilvy" wrote in message
...

for checkboxes from the control toolbox toolbar on a worksheet

Dim obj as OleObject
Dim cnt as Long
Dim chkbx as Msforms.Checkbox
For each obj in Activesheet.OleObject
if typeof obj.Object is MsForms.Checkbox then
set chkbx = obj.Object
if chkbx = True then
cnt = cnt + 1
end if
end if
Next

For forms controls on a worksheet

Dim chkbx as Checkbox
Dim cnt as Long
for each chkbx in Activesheet.Checkboxes
if chkbx.Value = xlOn then
cnt = cnt + 1
end if
Next

--
Regards,
Tom Ogilvy


"Steven" wrote in message
...
Looking for a way to count the number of checkboxes with a check in

them.

Thanks for your time,
Steven






Steven

Count Checkboxes.
 
Is there a quick way to link cells or do I have to go one by one

Thanks Again.

Tom Ogilvy

Count Checkboxes.
 
One by one (either manually or with a macro).

--
Regards,
Tom Ogilvy

"Steven" wrote in message
...
Is there a quick way to link cells or do I have to go one by one?

Thanks Again.





All times are GMT +1. The time now is 02:24 AM.

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