MrExcel Publishing
Your One Stop for Excel Tips & Solutions

Linking option buttons to cells


Posted by Alan H on March 28, 2001 11:36 AM

I have created 3 option buttons in a group on a user form. All 3 buttons are linked separately to 3 worksheet cells with the following line of code in VBA:
Range("Named_Cell").Value=opt_btn.Value How do I get the other cells' values to return to "False" once I select another option button in my group of 3? Or, in other words, how do I get only of the 3 cells linked to the 3 option buttons to show "TRUE" at any one time?


Posted by Dave Hawley on March 28, 2001 1:09 PM

Hi Allan

Try this:

Private Sub OptionButton1_Click()
OptValue
End Sub

Private Sub OptionButton2_Click()
OptValue
End Sub

Private Sub OptionButton3_Click()
OptValue
End Sub


Private Sub OptValue()
Range("A1") = OptionButton1
Range("A2") = OptionButton2
Range("A3") = OptionButton3
End Sub


Dave

OzGrid Business Applications

Posted by Alan H on March 29, 2001 12:13 PM


Thanks Dave!

It works just fine.