+ Reply to Thread
Results 1 to 6 of 6

Option Box buttons in UserForm help

  1. #1
    Registered User
    Join Date
    07-26-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Option Box buttons in UserForm help

    I apologize if this has been answered elsewhere, but I've been searching for the last 2 hours without finding help specific to my needs.

    I have an Excel template in which I want to launch an administrator options dialog box (back-end maintenance). I have started by inserting a command button form on a worksheet, which is linked to a 'UserForm named AdminControl (clicking the button to launch the dialog box. The AdminControl UserForm includes an option box with 3 radio buttons and an OK button a Cancel button at the bottom (image attached).

    I don't need help with the code for the individual options, but I do need help getting the AdminControl UserForm to run the code specific to each option. For example, I would like to be able to select either of the first 2 options and then run their respective code when I click on the OK button at the bottom; or be able to click on the third option and have the 'Enable' and 'Disable' buttons appear, and have specific code run when I select Enable or Disable.

    If I'm leaving out any important information, please let me know--I'm fairly new to VBA. Thanks in advance for any help.
    Attached Images Attached Images

  2. #2
    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: Option Box buttons in UserForm help

    Hello motolich,

    Welcome to the Forum!

    If you want want the user to make multiple choices then Option buttons are not going to work. Option buttons only allow one to be set at a time. You will need to CheckBoxes.
    Your button code will need to check the states of the options selected using IF THEN statements to perform conditional actions. To make the buttons appear or disappear, set the VISIBLE property to either True or False.
    Enter the code for the buttons in the button's CLICK event.
    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!)

  3. #3
    Registered User
    Join Date
    07-26-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Option Box buttons in UserForm help

    Thanks. I'm not looking for multi-select (admin using this feature needs to choose one of the three listed options). My trouble is figuring out the code that will allow user to select one of the three options, and click--for the first two options only--the OK button to execute code, and in the case of selecting the third option clicking either the Enable or the Disable button to execute code. I hope I'm making sense. I have tried various scenarios of If Then and the Visible options, but the problem persists that I'm unable to get the correct vba code to determine which radio button is selected, and then run the applicable code by clicking a command button. Thanks again.
    Last edited by motolich; 07-26-2013 at 06:45 PM.

  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: Option Box buttons in UserForm help

    Hello motolich,

    To expedite a solution, you should post a copy of your workbook. This will allow all code to be tested against actual the data and layout. If your workbook contains sensistive information, please redact it before posting.

    How To Post Your Workbook
    1. At the bottom right of the Reply window, Click the button Go Advanced
    2. At the top of the Your Message Window, in the first row of icons, Click the Paperclip icon.
    3. Click the Add Files button at the top right in the dialog box. This displays the File Manager dialog.
    4. Click the Select Files button at the bottom middle of the dialog.
    5. In the new window Find the file you want to upload, select it, and Click Open.
    6. You will now be back in the File Manager dialog. Click the bottom Middle button Upload File.
    7. Wait until the file has completely uploaded before you exit the File Manager dialog.

    File Manger Picture

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

    Re: Option Box buttons in UserForm help

    I think this will do what you want, once you write the code for the various functions.


    Please Login or Register  to view this content.
    Since the Enable/Disable buttons are visible only if optPassword is the checked option button, there is no need to add code to the cmdEnable to verify that optPassword is the one that is checked.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  6. #6
    Registered User
    Join Date
    07-26-2013
    Location
    Atlanta, GA
    MS-Off Ver
    Excel 2010
    Posts
    7

    Re: Option Box buttons in UserForm help

    Thanks, Mike! It worked.
    With a couple of minor tweaks, I was able to incorporate your instructions into my code and make it work. This was really helpful, especially since I startedusing VBA in Excel only a couple of days ago.

+ 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. UserForm with option buttons for a survey
    By JimmyG. in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-22-2013, 06:15 AM
  2. Userform Summing Option buttons
    By flebber in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 09-23-2010, 08:21 AM
  3. userform with frame and option buttons
    By erich_7719 in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 04-25-2008, 11:57 AM
  4. Help with a option buttons located in a userform
    By mav93 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-01-2006, 01:40 PM
  5. Changing text size in option buttons on a userform
    By Coen Burger in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 08-07-2005, 05:05 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