How to pass location/range of button into a macro?

Kelvin Stott

Active Member
Joined
Oct 26, 2010
Messages
338
Hello,

I hope everyone is well, and that at least one of you can please help...

I've created a button to run a macro, but need to pass the location/range of that button into the macro when it is clicked. Is there any way to do this so that the range is correctly identified when I move or copy the button to a different cell?

How do I identify the location/range of a specific button when it is pressed, if there are multiple copies of the same button?

Any help would be appreciated, thanks!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
If you are using Forms buttons rather than activeX then in your assigned macro you can use:
Code:
Activesheet.buttons(application.caller).Topleftcell
to refer to the cell under the top left corner of whichever button called the macro.
 
Upvote 0
Kelvin

Instead of Buttons you could try Shapes.
 
Upvote 0

Forum statistics

Threads
1,224,517
Messages
6,179,237
Members
452,898
Latest member
Capolavoro009

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