Having a macro recognize when an option button has been selected

G

Guest

Hi,

I'm trying to an IF THEN statement which is based on which one of two option
buttons was last selected. I have two option buttons ("OptionButton1" and
"OptionButton2" -- both from the 'Forms' menu) -- basically I'm trying to
create a macro that will look at which button is currently selected (this
button will already have it's radio button showing as being selected) and
will then execute code specific to which button it finds as being last
selected. Basically, I want the following:

'If 'OptionButton1' is slected, then:

Sheets("2nd Level Sources & Conv").Range("F27").Value = "Equivalent kwh/yr"

Else

Sheets("2nd Level Sources & Conv").Range("F27").Value = "Actual kwh/yr"

End If


Thanks for your help!

Rob
 
G

Guest

You may need to edit the option button name but something like:

With Sheets("2nd Level Sources & Conv")
If .OptionButtons("Option Button 1") = 1 Then
.Range("F27").Value = "Equivalent kwh/yr"
Else
.Range("F27").Value = "Actual kwh/yr"
End If
End With

Hope this helps
Rowan
 
G

Guest

Thanks!!

Rowan said:
You may need to edit the option button name but something like:

With Sheets("2nd Level Sources & Conv")
If .OptionButtons("Option Button 1") = 1 Then
.Range("F27").Value = "Equivalent kwh/yr"
Else
.Range("F27").Value = "Actual kwh/yr"
End If
End With

Hope this helps
Rowan
 

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