Excel basic macro help

jared511

Board Regular
Joined
Jul 28, 2009
Messages
192
Hello,

I created a macro that is very simple. I linked the macro to a button that is also on the spreadsheet. When you click the button all the macro does it =randombetween(a1,b1)

that's it.

However whenever I enter any information on the sheet seperate from the macro, it triggers the macro to run and changes the result. Any idea how to stop it from running and restrict it only to run when I click the button?


Thanks,
Jared
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Try like this

Code:
With Range("A1")
    .Formula = "=randbetween(a1,b1)"
    .Value = .Value
End With
 
Upvote 0
I want the result to populate in cell G16. Can you add that to your macro? And thanks so much for your help!
 
Upvote 0
That would be

Code:
With Range("G16")
    .Formula = "=randbetween(a1,b1)"
    .Value = .Value
End With
 
Upvote 0

Forum statistics

Threads
1,224,506
Messages
6,179,159
Members
452,892
Latest member
yadavagiri

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