Options Button Resetting on File Close

Heronz

New Member
Joined
Feb 13, 2004
Messages
9
I have 45 questions that each has 9 option buttons to select from. Each option button returns a vlaue which is placed into a particular cell in another sheet.

What I want to do is re-set the option buttons to a particular button number on exit - so that each time you open the file it is set in a neutral state ready for the questions to be asked.

i have tried changing the settings in the properties tab for the options buttons but this does not hold after the initial selection is made.

Is there something else that I need to do - or do I need to put a code in the virtual basic part of the sheet to reset certain buttons ??
 

Some videos you may like

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.

MartinK

Active Member
Joined
Oct 30, 2003
Messages
384
Hello,
we would need to know more about how your options are grouped, what are the values, etc.
In general, this will set the Optionbutton1 to True when you close your workbook:
Code:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
    Worksheets(1).OptionButton1 = True
End Sub
Martin
 

Heronz

New Member
Joined
Feb 13, 2004
Messages
9
Where you have

Worksheets (1) . ....

Do I put inside the brackets the name of the worksheet??
 

MartinK

Active Member
Joined
Oct 30, 2003
Messages
384
No, index. You can also use:

Sheets(1) for the first sheet or Sheets("Yournamehere") for the name.

Edit,
Worksheets("nameHere") works also, sorry.
 

Heronz

New Member
Joined
Feb 13, 2004
Messages
9

ADVERTISEMENT

Great thanks for that - I'll give that a try
 

Heronz

New Member
Joined
Feb 13, 2004
Messages
9
RAN INTO TROUBLE

It comes back with an error message -

ambiguous name detected: Workbook_BeforeClose

What does that mean?
 

MartinK

Active Member
Joined
Oct 30, 2003
Messages
384
It means that you have two procedures with the same name.
In ThisWorkbook class module check that you have just one procedure with this name.
If you need both, combine the code into one.
 

Watch MrExcel Video

Forum statistics

Threads
1,123,143
Messages
5,599,975
Members
414,354
Latest member
Flaxarn

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top