If macro help needed.

slm7678

Board Regular
Joined
Sep 26, 2002
Messages
60
hello all,

long time no post. i am trying to write some code for a command button.
what i have are two option buttons and one command button.
what i would like for it to do would be this:

if option button 1 is true then take A2*10 when command button is pressed

if option button 2 is true then take A2*20 when command button is pressed.
(these are simplified examples but i think i can work the rest in if i get a good starting place.)

im not sure how to proceed. im pretty sure i want an if then statement but i leave it in your capable hands.

TIA
Shannon
 

Excel Facts

How to total the visible cells?
From the first blank cell below a filtered data set, press Alt+=. Instead of SUM, you will get SUBTOTAL(9,)

TommyGun

MrExcel MVP
Joined
Dec 9, 2002
Messages
4,202
Code:
If OptionButton1 Then
    Range("B2") = Range("A2") * 10
ElseIf OptionButton2 Then
    Range("B2") = Range("A2") * 20
Else
    Range("B2") = Range("A2")
End If
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,167,956
Messages
5,856,507
Members
431,819
Latest member
hellosunshine

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
Top