+ Reply to Thread
Results 1 to 4 of 4

VBA code not recognising selected option button

  1. #1
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    VBA code not recognising selected option button

    Hi,

    I am creating a simple userform to change the view of a sheet depending on which option has been selected. There are 3 option buttons on the form (optAll, optDeco, optGlaze) and I have set the value to true for optAll.

    When the user clicks the 'OK' image (I prefer things to look nice instead of using standard buttons) the below code doesn't recognise which option is selected and skips to the msgbox line:

    Please Login or Register  to view this content.
    I already have created another form with options using the same approach without an errors. Can anyone shed any light as to where I may be going wrong?

    Thanks
    Harribone
    Say thanks, click *

  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: VBA code not recognising selected option button

    Difficult to comment without seeing the workbook, but why not just attach whatever code you want to run to the click event of the option buttons. It's not clear why you need to select an option and then click another object like an image.
    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
    Valued Forum Contributor Harribone's Avatar
    Join Date
    02-24-2013
    Location
    Midlands, UK
    MS-Off Ver
    Excel 2019/365
    Posts
    570

    Re: VBA code not recognising selected option button

    Hi Rich,

    Sorry ignore me!

    I've just realised that I haven't put 'Exit Sub' within the If statements hence why I though it was jumping to the MsgBox line.
    I think I need a coffee to wake myself up!


    On a side note the image that is clicked is in place of an OK button. If the code ran on selection of an option then I am assuming the user has selected the right option first time which may not always be the case (my users computer skills are to be considered non existent so am making room for human error doing this).

    Appreciate the quick response though,

    Thanks
    Harribone

  4. #4
    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: VBA code not recognising selected option button

    Quote Originally Posted by Harribone View Post
    Hi Rich,

    On a side note the image that is clicked is in place of an OK button. If the code ran on selection of an option then I am assuming the user has selected the right option first time which may not always be the case (my users computer skills are to be considered non existent so am making room for human error doing this).

    Thanks
    Harribone
    I understand your concern but if the user can't be relied on to select the right button first time and he knows that his next step is to click an OK button, that sort of user isn't going to hang around thinking have I selected the right option, they'd just click the OK button without thinking. It's human nature.

    It does raise the obvious question though and that's what IS the right button as far as that user is concerned and how would you know whether he'd selected the 'right' button or not.

    Suppose the wrong selection is made on the first occasion, is there any reason why another option button can't be selected to correct the first process?

+ 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. Make Sure a Option Button Is Selected
    By Jimbob 2705 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-20-2014, 06:24 PM
  2. Replies: 2
    Last Post: 08-15-2013, 12:25 PM
  3. [SOLVED] Command button grayed out till option button selected
    By Jeff121 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 07-25-2013, 11:00 AM
  4. Message to Display when Option Button is selected
    By George3232 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 06-29-2010, 11:04 AM
  5. selected option button assign 1 to a cell and others 0
    By hjk in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-16-2007, 03:27 PM
  6. Option Button - multiple selected
    By alanap in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 04-17-2006, 06:10 PM
  7. If option button not selected
    By Hywel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-08-2005, 05:32 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