The use of options button (I'm sure theres a quick solution)

clares

Well-known Member
Joined
Mar 14, 2002
Messages
557
I'm sure there is an easy way but have spent a while trying to it work out. I have put two option buttons on a dialog sheet (dialog1) and I am trying to write an if statement but can not seem to determine which button has been pressed. Can anyone help!!

Thank you in advance
 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
To tell if an optionbutton has been pressed use the following:

if optionbutton1.value=true then
msgbox "Option Button 1 has been pressed"
elseif optionbutton2.value=true then
msgbox "Option Button 2 has been pressed"
end if
 
Upvote 0
Do I have to substite "optionbutton1" with the name that I have given it?

On 2002-03-22 08:55, Al Chara wrote:
To tell if an optionbutton has been pressed use the following:

if optionbutton1.value=true then
msgbox "Option Button 1 has been pressed"
elseif optionbutton2.value=true then
msgbox "Option Button 2 has been pressed"
end if

[/quote]
 
Upvote 0
AlChara has your solution. Make sure this code is placed in the option button's change or click event. Other events could be used as well...

Have Fun!
 
Upvote 0

Forum statistics

Threads
1,214,386
Messages
6,119,216
Members
448,876
Latest member
Solitario

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