+ Reply to Thread
Results 1 to 8 of 8

Unselect OptionButton. How to?

  1. #1
    Matt
    Guest

    Unselect OptionButton. How to?

    Folks,

    I have a macro with a data input screen.

    Amongst others there are 5 optionbuttons. The macor must not continue
    without one checked.

    I do that by each subroutine of each option button writes the value 1
    in a cell.

    If there is no value 1 in that cell the macro will clear all selections
    restart.

    The problem is that now it cleared the 1 and it thinks no button is
    selected, but really the button is STILL selected.

    Is there a way to uncheck these buttons from inside the macro? OR at
    least reset them all to default, like when the macro starts the first
    time?

    Thanks!
    Matt


  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
    Hello Matt,

    Since you don't say if the buttons are on a worksheet or a user form, I am giving methods for either type of button.

    Forms Toolbar Option Button

    Sub ClearOptionButton()

    Shapes("Option Button 1").ControlFormat.Value = False

    End Sub


    To set the button, change False to True.


    Control Toolbox (VBA)

    Sub ClearOptionButton()

    OptionButton1.Value = False

    End Sub


    The Option Button Control name is in Red. Change this to match the name of the control to be reset.

    Sincerely,
    Leith Ross

  3. #3
    Matt
    Guest

    Re: Unselect OptionButton. How to?

    Its on a user form. Thanks for your help!

    Will be able to try it on monday...

    Matt


  4. #4
    Matt
    Guest

    Re: Unselect OptionButton. How to?

    Works like a charm

    Even better I am now (trying) to use Rowsource to select the range for
    the drop down menu based on the amount of cells I have (varies all the
    time).

    Now the problem is that if I select rowsource before I open the form it
    gives an error and otherwiese the dropdown menu wont adjust its size
    until after the user clicks somehting..

    How can I use the rowsource for a combox command before the form is
    visible?

    Matt


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

    Generally when you link a editing object (Textbox, ComboBox) to a cell it is pass the information from the control to the worksheet cell. You are doing the reverse. You can more than likely use another method to load the ComboBox based on the cells. Can you post or emial your workbook so I can see what you are doing? I will faster than doing multiple posts trying to explain.

    Thanks,
    Leith Ross

  6. #6
    Matt
    Guest

    Re: Unselect OptionButton. How to?

    Hi Leith,

    thanks for your offer to help! I was able to solve the problem by
    useing a suggestion posted by some of the other guys. But I am still
    having problems with weird textbox behaviour...

    I cant seem to retrieve your email address though

    Matt


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

    My email is [email protected].

    Sincerely,
    Leith Ross
    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!)

  8. #8
    Registered User
    Join Date
    07-13-2016
    Location
    Tehran - Iran
    MS-Off Ver
    2016
    Posts
    1

    Re: Unselect OptionButton. How to?

    Thanks Leith Ross

+ 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