• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Count Checked status of Checkbox

Hello,
I have a userform set up such that it has a 4 CheckBoxes on it. How can I Count the number of Checked CheckBoxes when the user checkmarks it on the form and depending on the checked status, it writes either a TRUE or FALSE value to the worksheet. I would like to count only the checked values of the Checkboxes on the userform with a formula entered through VBA code. How can this be done ? Thanks for all responses.
Regards,
 
Maneesh

Try the following, assuming that the Check Boxes link to cells A1:A4

Code:
Set myRange = Range("A1:A4")
x = WorksheetFunction.CountIfs(myRange, "True")
 
Thanks for helping once again Hui. Was just curious, will the same code work for a dynamic named range or needs some alteration? I haven't tried it yet, but I'll work through it today.
 
Say you had a Named Formula as
myRange: =OFFSET(Sheet1!$A$1,,,COUNTA(Sheet1!$A:$A),1)

then use
Code:
x = WorksheetFunction.CountIfs([myRange], "True")

No need for the Set line
 
In the original case you could have used:

Code:
x = WorksheetFunction.CountIfs([A1:A4], "True")
 
Back
Top