# Microsoft Office Application Help - Excel Help forum > Excel Programming / VBA / Macros >  > [SOLVED] Unselect OptionButton. How to?

## Matt

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

----------


## Leith Ross

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

----------


## Matt

Its on a user form. Thanks for your help!  :Smilie: 

Will be able to try it on monday...

Matt

----------


## Matt

Works like a charm  :Smilie: 

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

----------


## Leith Ross

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

----------


## Matt

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  :Frown: 

Matt

----------


## Leith Ross

Hello Matt,

My email is LeithRoss@aol.com.

Sincerely,
Leith Ross

----------


## Mehdi-Kamankesh

Thanks Leith Ross

----------

