+ Reply to Thread
Results 1 to 4 of 4

Need to Count number of Check Boxes checked on a userform

  1. #1
    Registered User
    Join Date
    02-04-2014
    Location
    Baltimore, Maryland
    MS-Off Ver
    Excel 2010
    Posts
    17

    Need to Count number of Check Boxes checked on a userform

    I have a userform with multiple check boxes and I want to count the number of boxes that are checked.

    There are nearly 70 options to check and do not know how to use a variable within the (Name) for the checkbox to change so I can use a for loop. I have used the naming convention of each check box as : CheckBox2, CheckBox3, CheckBox4... etc... to CheckBox70.

    I was wondering if there is a way to use a variable to represent the number of the checkbox being referenced. Essentially, I need to count the number of checkboxes that are checked/true so I can insert that number of rows into my excel sheet and ultimately enter that checked data into those respectively inserted rows.

    Please help!!!

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Need to Count number of Check Boxes checked on a userform

    Hi,
    there are two ways to do this.
    First - use custom class and change the counter every time when checkbox is checked/unchecked. It's more complicated and maybe a bit of overkill depending on what your needs are.

    Second option - more simple. loop trough controls on the form when some button (e.g.OK button) is clicked, count the number of checked checkboxes and use it in the code after that
    here is macro that will do the second option

    Please Login or Register  to view this content.
    Last edited by buran; 02-12-2014 at 03:40 PM.
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Forum Expert Ron Coderre's Avatar
    Join Date
    03-22-2005
    Location
    Boston, Massachusetts
    MS-Off Ver
    2013, 2016, O365
    Posts
    6,996

    Re: Need to Count number of Check Boxes checked on a userform

    Is this something you can work with?
    Please Login or Register  to view this content.
    Oops! Nevermind...You have checkboxes on a UserForm...not worksheet.
    Ron
    Former Microsoft MVP - Excel (2006 - 2015)
    Click here to see the Forum Rules

  4. #4
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Need to Count number of Check Boxes checked on a userform

    Hello UMBiii,

    Ron had the right idea. For a VBA UserForm the loop would look like this.
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] How to Count Check Boxes and count the total number of boxes checked
    By t04904 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-12-2013, 11:45 AM
  2. Count number of checked boxes
    By Motox502 in forum Excel - New Users/Basics
    Replies: 3
    Last Post: 07-02-2012, 03:11 PM
  3. Number of check boxes checked
    By mraheelgujjar in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-26-2011, 08:32 AM
  4. In Excel, how to count a list of check boxes some are checked?
    By M. Zak in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 01-26-2006, 05:55 PM
  5. I want to be able to count the number of checked boxes in a form?
    By cldavis in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 11-21-2005, 05:55 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1