Insert text with option button

adamsm

Active Member
Joined
Apr 20, 2010
Messages
444
Hi anyone,

How could I write a code that would display the text in textbox1 when the option buton1 is selected.

Lets say for example; If I select option button1 I want the text box to display the text "me" with the option button2 to display "he"

Any help on this would be kindly appreciated.

Thanks in advance.
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Code:
Private Sub OptionButton1_Click()
    TextBox1.Value = "me"
End Sub

Private Sub OptionButton2_Click()
    TextBox1.Value = "he"
End Sub
 
Upvote 0
Thanks for the code. How could I create a message "select category first" if the user selects a radio button having the combo box1 empty.

Any help on this would be kindly appreciated.
 
Upvote 0
Maybe this:
Code:
Private Sub OptionButton1_Click()
    If ComboBox1.ListIndex = -1 Then
        MsgBox "Select category first"
    Else
        TextBox1.Value = "me"
    End If
End Sub

Private Sub OptionButton2_Click()
    If ComboBox1.ListIndex = -1 Then
        MsgBox "Select category first"
    Else
        TextBox1.Value = "he"
    End If
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,525
Messages
6,179,319
Members
452,905
Latest member
deadwings

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
Back
Top