+ Reply to Thread
Results 1 to 4 of 4

Only 1 option to be selected in userform

Hybrid View

  1. #1
    Registered User
    Join Date
    04-08-2014
    Location
    Oz
    MS-Off Ver
    Excel 2013
    Posts
    63

    Only 1 option to be selected in userform

    Hello

    I am using this code on a userform. I double click and the userform opens. Can the code be altered to achieve this below

    1. Only 1 option can be selected. I can select all 3 currently

    2. Set a specific cell range for the userform to work (A3:Y89 & A121:Y250).Out of the range and the userform is not available

    3. When the Press button selected then the userform shuts down

    Any help appreciated

    Andy Tap
    Excel 2010/2016
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Only 1 option to be selected in userform

    Hi,

    1. Use three Option Buttons instead of Check Boxes. Then you can avoid the CommandButton altogether. Use the Click event of each option button to set the cell value to T, A or C. e.g.
    Private Sub OptionButton1_Click()
        Selection = "A"
        Unload frmSelectionOption
    
    End Sub
    This also deals with item 3 since the form will shut down after the Option button is clicked.

    To restrict the range create two range names 'Range1' and 'Range2' and use the sheet Double click event event. i.e.

    Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
        If Not Intersect(Target, Range("Range1")) Is Nothing Or Not Intersect(Target, Range("Range2")) Is Nothing Then
    
            frmSelectionOption.Show
    
        End If
    
    End Sub
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    06-06-2016
    Location
    Hampshire
    MS-Off Ver
    2013
    Posts
    19

    Re: Only 1 option to be selected in userform

    Hi,
    See if this update to your workbook does what you want.

    Dave

    Edit:

    In CommandButton1_Click I omitted line

     Unload Me
    Attached Files Attached Files
    Last edited by Exited; 07-31-2016 at 11:11 AM.

  4. #4
    Registered User
    Join Date
    04-08-2014
    Location
    Oz
    MS-Off Ver
    Excel 2013
    Posts
    63

    Re: Only 1 option to be selected in userform

    G`Day Richard & Dave
    Thanks for solving the issue. This now works perfectly
    Cheers
    Andy

+ 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. VBA Userform: Add selected userform value to selected any cell
    By nimesh29 in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 08-06-2014, 09:14 PM
  2. [SOLVED] Textbox and Option Buttons - If Textbox has a Value then an Option Button must be selected
    By MeerkatMatt in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 07-08-2014, 07:45 AM
  3. Returning the row number of the option after the selected option in a userform combobox
    By rep67439fgs in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2014, 08:07 AM
  4. Replies: 2
    Last Post: 08-15-2013, 12:25 PM
  5. Activate Print option with a userform where selected Sheet check box option available..
    By santosh226001 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-03-2013, 08:19 AM
  6. Userform Option Button to Show/Hide Another Option Button on same Userform
    By R_S_6 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-26-2010, 09:44 AM
  7. Option buttons: How to get the selected option from a group?
    By naddad in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 12-21-2005, 01:10 PM

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