PDA

View Full Version : OptionButton madness...



Glaswegian
10-04-2007, 02:34 AM
Hi folks

I have 2 sets of optionbuttons - each one is being used as a Yes/No answer to a question. Depending on the answer, text is either hidden or revealed. All pretty simple.

However, if I leave the sheet, having chosen an option, when I return, both optionbuttons are blank - the selected values are not being retained. This is repeated over 3 sheets - each sheet has the same buttons and questions. There is no code running to clear the options. Below is the code for one of the buttons, just for info...

Private Sub OptionButton5_Click()
If OptionButton5 Then Range("P15").Font.ColorIndex = 5
End Sub

Why won't they retain their selected value?

Charlize
10-04-2007, 02:40 AM
When you activate your sheet, check on the colorindex for P15. If it's not the desired color, optionbutton5 wasn't chosen, so that value for optionbutton5 was false. If P15 has the desired color, optionbutton5 = true. (I guess).

Glaswegian
10-04-2007, 02:45 AM
I see what you mean, but why won't the button retain its previously chosen value? That's the bit I don't understand.

Charlize
10-04-2007, 03:02 AM
I see what you mean, but why won't the button retain its previously chosen value? That's the bit I don't understand.Maybe you're resetting them ? Some code on Workbook_SheetChange ? And you're not in design mode ?

Charlize
10-04-2007, 03:05 AM
Private Sub OptionButton5_Click()
If OptionButton5 Then Range("P15").Font.ColorIndex = 5
End Sub

Why won't they retain their selected value?Why an if ? If you click on the optionbutton, you know it's going to be true.

Glaswegian
10-04-2007, 06:19 AM
That's an 'Oooops' moment...

There are no Sheet Change Events running, nor any other code that would affect them.

I decided just to change to checkboxes and all works just fine now.

Thanks for your help.