+ Reply to Thread
Results 1 to 7 of 7

Radio Button default Selection

  1. #1
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Radio Button default Selection

    I have a Userform (frmData) with 4 CommandButtons (Cmd1, Cmd2 etc) and also 2 RadioButtons (Opt1 & Opt2).

    I want Opt1 to be the default selection when frmData is opened.
    If Opt1 or Opt2 is selected I want that option to stay selected until frmData is closed.

    When Cmd1 is selected code1 runs if Opt1 is ticked, and Code2 if Opt2 is selected.

    I need help with the code to get the above working.

    Thanks Sandy

  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,259

    Re: Radio Button default Selection

    Hello gsandy,

    Option Buttons are mutually exclusive when placed on a UserForm. That means if one is set the others will automatically be cleared. The only time this behaviour changes is if the Option Buttons are in different frames. To answer your question, you need to post your workbook.
    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
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Radio Button default Selection

    Hi Leith,

    I have attached my spreadsheet. When "Glulam" is selected (on frmData) and then "Enter Data" (on frmGL), "LineInsert" code runs. Which adds a line after the last entry. This is to be the default.
    If a RadioButton (I probabally only need one) is selected on frmData and then "Enter Data" is selected on frmGL, a new code "LineInsertA" (I have yet to write) runs.

    If the RadioButton is selected I want it to stay selected until frmData is closed. When frmData is reopened the RadioButton should be unselected.

    Hope this make sense. Sandy
    Attached Files Attached Files

  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,259

    Re: Radio Button default Selection

    Hello Sandy,

    I added a frame for the option buttons. The reason is this makes it easier to deactivate the others in the group. Here is the code I have added to the User Form. These changes have been added to the attached workbook.
    Please Login or Register  to view this content.
    Attached Files Attached Files

  5. #5
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Radio Button default Selection

    Hi Leith,

    Almost there.
    I see that the code in the RadioButton [OptionButton1_Click()] runs as soon as it is selected.
    What I want is for the RadioButton to determine which code runs after the CommandButton "Enter Data" is selected in either frmGL or frmSRect.
    The Code that runs now is "LineInsert" and after the RadioButtons are working "LineInsert" or "LineInsertA" (a modified version of "LineInsert") will run.

    Thanks Sandy

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

    Re: Radio Button default Selection

    Hello Sandy,

    I had to run to the store for my wife. Now that I'm finally back, I can answer your question. I changed the macro to store which Option Button was selected in Frame1's Tag property. This is a string whose lifetime is as long as the User Form is displayed. Since both forms will be open at the same time, this property can pass the information from the first form to the second. The attached workbook has these changes added to it.

    frmData
    Please Login or Register  to view this content.
    frmGL
    Please Login or Register  to view this content.
    Attached Files Attached Files

  7. #7
    Forum Contributor
    Join Date
    02-26-2009
    Location
    Auckland, New Zealand
    MS-Off Ver
    Excel 2010
    Posts
    286

    Re: Radio Button default Selection

    Hi Leith,

    Sorry about the delayed thanks, but computer/internet problems today have caused headaches. My first use of RadioButtons is now working, thanks.

    Spent 5 weeks at your neck of the woods a couple of months ago. Our last fews days were at the Golden Gate National Rec Area near Sausalito, had a great time.

    Sandy

+ 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