+ Reply to Thread
Results 1 to 10 of 10

Loop to add up values of selected check boxes

  1. #1
    Registered User
    Join Date
    10-13-2012
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2010
    Posts
    13

    Loop to add up values of selected check boxes

    I have a Userform that has ~30 check boxes (chkbx1,...chkbx30). Each check box represents a numerical value. When the user submits the form I would like to sum the total value of all selected check boxes.

    How can i do this?

  2. #2
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Loop to add up values of selected check boxes

    is the value the caption?

    if so something like
    Please Login or Register  to view this content.
    **this only works if the caption is only the number
    Last edited by humdingaling; 07-31-2013 at 12:38 AM.
    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

  3. #3
    Registered User
    Join Date
    10-13-2012
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Loop to add up values of selected check boxes

    No, sorry the caption is not the number value I want to tally.

  4. #4
    Forum Expert
    Join Date
    08-12-2012
    Location
    Sydney, Australia
    MS-Off Ver
    Excel 2010
    Posts
    5,636

    Re: Loop to add up values of selected check boxes

    what/how/where is the number do you want to tally then?

  5. #5
    Registered User
    Join Date
    10-13-2012
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Loop to add up values of selected check boxes

    i have an if value=true assignment
    Please Login or Register  to view this content.
    there is probably a better way to do it, but I am not sure how.

  6. #6
    Registered User
    Join Date
    10-13-2012
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Loop to add up values of selected check boxes

    *duplicate post*
    Last edited by lbi; 07-31-2013 at 11:13 AM.

  7. #7
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Loop to add up values of selected check boxes

    Can you clarify exactly what you have?

    In the first post you say the checkboxes are named chkbx1, chkbx2 etc but in the code in the last post you seem to have controls named BL and BT.

    Also, where do the values for each checkbox come from?
    If posting code please use code tags, see here.

  8. #8
    Registered User
    Join Date
    10-13-2012
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Loop to add up values of selected check boxes

    Sorry, I have been continuing to work on this and modifying the original code.

    The check boxes are named using 2 letter codes representing a longer name for a charge for that check box.

    The end result will be this:

    User selects a task from a drop down, then checks-off the appropriate boxes that calculate the charge for that task.

    I have the drop down list generated and the check boxes created.

    I am willing to change how the check boxes are displayed if that makes it easiest to accomplish this, but currently the Caption is more of a description than integer value. Should I need to change the Caption to the value, I can overwrite with a label.

  9. #9
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Loop to add up values of selected check boxes

    You don't need to change the caption, there are other ways to store the value.

    For example you could use the Tag property of the checkboxes.

    You could even store them on a worksheet and use a lookup based on the current captions.

    Unless you do something like that you'll find yourself repeating code like that you posted in #5 for each checkbox.

    By the way, have you considered using a listbox do list all the charges?

    It could be set up to show a checkbox next to each charge and the value could be stored in a hidden column.

    With that it would be simple to add up the values, all you would need to do is loop through the list in the listbox.

  10. #10
    Registered User
    Join Date
    10-13-2012
    Location
    Vancouver, BC
    MS-Off Ver
    Excel 2010
    Posts
    13

    Re: Loop to add up values of selected check boxes

    Thank you for the reply Norie.

    In fact all of these values are listed on a work sheet with the 2 letter code, full description as well as the charge value.

    A list box would be fine, but I dont want users having to scroll through to find everything. that was the appeal of the check boxes.

+ 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. I need a code for presence check to check multiple text boxes and combo boxes
    By Lee_wwfc in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-24-2013, 01:53 PM
  2. [SOLVED] Loop through check boxes, results in 1 cell
    By tbar05 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 02-14-2013, 12:48 AM
  3. Delete This Posting Please
    By dsannito in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 01-25-2013, 10:34 AM
  4. Replies: 1
    Last Post: 07-13-2012, 12:11 PM
  5. Replies: 2
    Last Post: 02-21-2012, 09:21 AM

Tags for this Thread

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