+ Reply to Thread
Results 1 to 13 of 13

Check for OptionButton selection

  1. #1
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Check for OptionButton selection

    Hi,

    I have 3 Frames in my userform which contain several optionbuttons in each frame. How can I be sure that in each of the 3 frames that atleast ONE selection has been made?

    I have started with this code:

    Please Login or Register  to view this content.
    I'm not sure how this should be written to check for a selection in all 3 frames and then Exit Sub if not.

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

    Re: Check for OptionButton selection

    Try this.
    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Check for OptionButton selection

    Thanks, Norie

    This works perfect. How would I display the Frame name in there?

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

    Re: Check for OptionButton selection

    After Next opt add something like this.
    Please Login or Register  to view this content.
    That could show multiple message boxes, so you might want to use some other method.

    For example you could build up a string and then display the message at the end.

  5. #5
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Check for OptionButton selection

    Excellent! Thank you Norie.... much appreciated!

  6. #6
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Check for OptionButton selection

    Norie,

    One more little thing I came across... what part resets the current selections? If I make a selection in frame 1, 2 or both and not 3, I get the error message but then the first selections clear out. How to prevent that?

    Please Login or Register  to view this content.

  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: Check for OptionButton selection

    Not sure what you mean the code doesn't make any selections.

  8. #8
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Check for OptionButton selection

    What happens in my frames is... I select an optionbutton in Frame1, an optionbutton in Frame2 and then no selection in Frame3. I get my message box that says I need to make a selection in Frame3. When I click OK, the first selections are gone.

  9. #9
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Check for OptionButton selection

    Sorry, I figured it out. I needed to EXIT SUB after the msgbox. It was continuing with the code and resetting my selections.

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

    Re: Check for OptionButton selection

    There's nothing in the code that changes anything on the userform.

    The code only checks the values of the option buttons.

    Where have you put this code?

    Is there any other code that could be causing the problem?

  11. #11
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Check for OptionButton selection

    Yes, hopefully you saw the last post. However, I have another curve ball. How can ignore all of this code if I have a single option button clicked in Frame 1 ? I will explain the best I can.... All 3 frames have defect selections.

    Frame 1: Defect
    Frame 2: Cause
    Frame 3: Solution

    So either in frame 1 or a single option button by itself that would be a "PASS" button which means everything passed and no selections needed.

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

    Re: Check for OptionButton selection

    Check that specific option button first.

    Something like this perhaps.
    Please Login or Register  to view this content.

  13. #13
    Forum Contributor
    Join Date
    04-03-2012
    Location
    Washington State
    MS-Off Ver
    Excel 365
    Posts
    340

    Re: Check for OptionButton selection

    Thanks ... this helps a lot. Much appreciated!

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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