Identifying the location of a Form Button

Zaephod

New Member
Joined
Mar 12, 2012
Messages
6
Hello,

I am looking for some code which will return the location of the form button which is being clicked on to activate the macro. I would like to avoid using an active.x button if at all possible.

In this way I can use the same macro on a column of buttons to trigger an action based on adjacent cell contents.

e.g.

Name Button
Mr a Button1
Mr b Button1
Mr c Button1

The aim is to use the button on an index tab and to capture the name next to the button as a sort string for data on a separate tab.
I am running Excel 2010 on Windows Xp.

Thanks for any tips.

James
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Hi James

You can use Application.Caller to return the name of the calling shape (as a string) and use that to determine the topleft cell of the calling shape eg:

Code:
MsgBox ActiveSheet.Shapes(Application.Caller).TopLeftCell.Address
 
Upvote 0
Hi, thanks for the quick reply.

Since I will have about 50 of these buttons per sheet I wanted to, if possible, avoid using active x controls. Do you know it there is a way of locating a bog standard form button?

Cheers,
James
 
Upvote 0
Firefly's code is for Forms buttons, not ActiveX.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,326
Members
452,635
Latest member
laura12345

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