Simple Macro - Change Cell

fedas18

Board Regular
Joined
Jan 21, 2010
Messages
81
Hi,

I am trying to write a macro (with a botton) that will change cell K3 to 1.

Any help?

Idk if its possible but if my botton could change K3 to 1 then back to 0 if I double click the botton that would be idea. If not no big deal.

Thanks!
 

Excel Facts

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Here is a simple little macro that will toggle the value of B3 between 1 and 0 whenever it is run.
Code:
Sub UpdateK3()
 
    If Range("K3").Value <> 1 Then
        Range("K3").Value = 1
    Else
        Range("K3").Value = 0
    End If
        
End Sub
Check out this link to see how you can create a button and attach that code to the button:
http://www.wikihow.com/Create-a-Custom-Macro-Button-in-Excel
 
Upvote 0
"<>" means "not equal to" (quite literally it means "greater than or less than").

So we are saying if K3 does not equal one when the button is pushed, set it equal to one. Otherwise, set it equal to zero.
 
Upvote 0

Forum statistics

Threads
1,224,574
Messages
6,179,626
Members
452,933
Latest member
patv

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