radio button text bold when clicked

  • Thread starter Thread starter dgold82
  • Start date Start date
D

dgold82

Is there a way to make the text of a radio button (option button from forms)
bold when clicked? Thanks.
 
Private Sub OptionButton1_Click()
Set but = ActiveSheet.OptionButton1
but.Font.Bold = True
End Sub
 
Thanks for the reply but unfortunately I am getting an error saying variable
not defined and highlighting "but ="

I am running excel 2007 and placed your code in the worksheet module. I also
placed it in a regular module but got the same error.

Also, I want to make it so that any option button on the page turns its text
bold when clicked/filled not specific to to just one option button. I have
over 200 option buttons on each worksheet...

Thanks!
 
That is because 'but' is not declared as some type of object. However, I
don't think the 'but' variable would even be needed. This is untested, but
try...

Private Sub OptionButton1_Click()
ActiveSheet.OptionButton1.Font.Bold = True
End Sub
 
Got a runtime error...

Rick Rothstein said:
That is because 'but' is not declared as some type of object. However, I
don't think the 'but' variable would even be needed. This is untested, but
try...

Private Sub OptionButton1_Click()
ActiveSheet.OptionButton1.Font.Bold = True
End Sub
 
I just re-read your original message and see you used an OptionButton from
the Form's toolbar... I'm pretty sure you can't change the font properties
on that type of control. Now, if you use an ActiveX OptionButton from the
Control Toolbox toolbar instead, then you can use this event code (it goes
on the worksheet's code window, *not* in a general Module) to make the font
bold whenever the OptionButton is selected...

Private Sub OptionButton1_Change()
With Sheet7.OptionButton1
.Font.Bold = .Value
End With
End Sub

Change the Sheet7 reference in my example code to the actual sheet name the
control is on.
 
you can use the other's suggestions, but if you have more than 1 optionbutton,
you would need to set the font to normal if someone changes their mind or makes
a mistake.

just a thought.
 
Back
Top