+ Reply to Thread
Results 1 to 9 of 9

Suggested vba code that applies to multiple check boxes

  1. #1
    Registered User
    Join Date
    06-22-2020
    Location
    NY, NY
    MS-Off Ver
    Windows 10
    Posts
    14

    Suggested vba code that applies to multiple check boxes

    Greetings

    An excel sheet is not necessary at present as a picture of the user-form will tell the simple situation.

    Sampleform.JPG

    I am looking for guidance to proceed with code to process approx., 100 check boxes (including the multi-tabs not shown). As shown on the sample form there are two check boxes per data-element; one to "Confirm" and one to "Update" the field directly to the right of the second check box.

    Basically, I want the user to click the 1st check box (if no changes are required) and the word "confirmed" appear in the "revised value" text box.

    If the data requires revision, then I want the user to click the 2nd check box and have the code put the cursor in the "revised value" text box for the users-input.

    I have searched and see many different approaches; however, just looking for general good practice guidance for me to proceed as I am not very experienced in vba.

    Your suggestions are most appreciated.

  2. #2
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Suggested vba code that applies to multiple check boxes

    see big yellow banner - how to upload a workbook - enables us to give a far more comprehensive advice.
    a casual observation - you also have 13 option buttons - what is there purpose as they do not seem to be separated - therefore only one would be selected.
    torachan.

  3. #3
    Registered User
    Join Date
    06-22-2020
    Location
    NY, NY
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: Suggested vba code that applies to multiple check boxes

    The option buttons are totally independent of each other and apply just to the line item to the left; such as "Acquisition Method Code".

    I could easily create an event for each "option button" and include an IF statement to add the word "confirmed" in the "revised value" text box to the right of the "option buttons." See my explanation above.

    However, I am seeking guidance on an alternate solution to NOT create a hundred events; perhaps there are other solutions more compact and more efficient.

    And yes, I see the yellow banner; however, my form is enormous (works very nicely) and accesses a source file with 300 columns from an oracle serve. So the reason for the graphic and not an actual file.

    Thanks,

  4. #4
    Registered User
    Join Date
    06-22-2020
    Location
    NY, NY
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: Suggested vba code that applies to multiple check boxes

    By the way, I'm referring to the 26 "Check boxes" not the 13 "option boxes."

  5. #5
    Forum Expert torachan's Avatar
    Join Date
    12-27-2012
    Location
    market harborough, england
    MS-Off Ver
    Excel 2010
    Posts
    4,411

    Re: Suggested vba code that applies to multiple check boxes

    merely an observation on the side - there is nothing to show the option buttons are contained and independent of each other - can you select more than one
    not many of us are prepared to construct a userform when one already exists.
    just makes sense to help us to help you solutions arrive quicker then.

  6. #6
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Suggested vba code that applies to multiple check boxes

    First, I would use OptionButtons for Confirmed/Update rather than the Check Boxes.
    I would also create a custom class, clsControlGroup. Each clsControlGroup has the CurrentValue textbox, the Record Data Label, a Confirmed Option Button, a Update Option Button, a Revised Value text box and an Attachment Option Button.

    Create a class module, change its name to clsControlGroup in the Property Window and put this code in that module
    Please Login or Register  to view this content.
    And then code like this in the Userform to get everything hooked up
    Please Login or Register  to view this content.
    My test file was for three rows.
    Note the ActiveControlGroup_Change event that fires when one of the three option buttons in a control group is clicked.

    If you need CheckBoxes rather than OptionButtons for Confirmed/Update, the data typing in clsControlGroup could be changed and code added to make sure that both weren't checked at the same time.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  7. #7
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,475

    Re: Suggested vba code that applies to multiple check boxes

    I agree with torachan comments fully. To add to them, any solution we might be able to suggest is probably going to be highly dependent on the names you gave to those checkboxes as well as the names you gave to the textboxes and how those names are linked to each other.

  8. #8
    Registered User
    Join Date
    06-22-2020
    Location
    NY, NY
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: Suggested vba code that applies to multiple check boxes

    This is the type of guidance I am seeking, a methodology; however, I have to get knowledgeable on "custom classes". This approach does present a complex solution though and your suggestion is most appreciated.

  9. #9
    Registered User
    Join Date
    06-22-2020
    Location
    NY, NY
    MS-Off Ver
    Windows 10
    Posts
    14

    Re: Suggested vba code that applies to multiple check boxes

    I meant to say a "compact solution."

+ 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. Using Check Box Code for Multiple Check Boxes
    By brentjohn in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-07-2018, 01:13 AM
  2. Check boxes that delete other check boxes and change the color of another cell.
    By nhamhamilton in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-29-2014, 02:40 PM
  3. [SOLVED] Coding Yes/No option buttons to not allow check boxes or require check boxes
    By HeyInKy in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-30-2014, 11:32 PM
  4. 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
  5. single group of code to reference multiple sequential names of active x check boxes
    By ferrum_equitis in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-01-2012, 03:25 AM
  6. Check Boxes (un-Check multiple Check Boxes)
    By robertguy in forum Excel General
    Replies: 0
    Last Post: 03-23-2005, 08:48 AM
  7. check boxes and VBA code
    By Paul in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-10-2005, 06:06 PM

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