Forms Option control cell

E

Epoh Rio

How can I control the value of one cell (A15) based on which option was
selected in an optionbox on a form?

Thanks,
 
C

Chip Pearson

You can use the Click event of each OptionButton, like the following:

Private Sub OptionButton1_Click()
If OptionButton1.Value Then
Range("A15").Value = 1
End If
End Sub

Private Sub OptionButton2_Click()
If OptionButton2.Value Then
Range("A15").Value = 2
End If
End Sub
Private Sub OptionButton3_Click()
If OptionButton3.Value Then
Range("A15").Value = 3
End If
End Sub

Or, in a separate procedure

Select Case True
Case OptionButton1.Value
Range("A15").Value = 1
Case OptionButton2.Value
Range("A15").Value = 2
Case OptionButton3.Value
Range("A15").Value = 3
Case Else
' no option button is selected
End Select
 
Top