Placing Optionbutton Value

P

Patrick Simonds

I have 3 optionbuttons (optionbutton1 - 3) which are in optiongroup lunch.
Since only one of the three button can be active, how would I place that
value of the active optionbutton in a cell.

optionbutton1 = 0
optionbutton2 = 30
optionbutton3 = 60
 
C

Colo

Patrick, please see the code below.

Private Sub OptionButton1_Click()
ActiveCell.Value = 0
End Sub

Private Sub OptionButton2_Click()
ActiveCell.Value = 30
End Sub

Private Sub OptionButton3_Click()
ActiveCell.Value = 60
End Sub
 
P

Patrick Simonds

I am hoping to do this when I click on a Finished commandbutton and have all
item (including the optionbutton selection) placed on the worksheet at the
same time.
 
C

Colo

So the code for the CommansButton would be something like this.


Private Sub CommandButton1_Click()
Dim lngValue As Long
If OptionButton1.Value Then lngValue = 0
If OptionButton2.Value Then lngValue = 30
If OptionButton3.Value Then lngValue = 60
ActiveCell.Value = lngValue
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top