ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Name of button (https://www.excelbanter.com/excel-programming/379723-re-name-button.html)

Dave Peterson

Name of button
 
these are buttons from the forms toolbar?

If you have a macro assigned to that button:

dim myBTN as Button
set myBTN = activesheet(application.caller)
msgbox mybtn.name & "- or - " & application.caller



Agamemnon wrote:

Hi

I have create a macro that put some buttons on a sheet.
As the buttons are created automatically I don't know what names they have.
So I would like to know how I can retrieve eg. in Cell sheet1!A1 the name of
the button I click on?

Can somebody help me out on this one?

Thx


--

Dave Peterson

Dave Peterson

Name of button
 
Sorry, it was a typo on my part:

set myBTN = activesheet.buttons(application.caller)

You can get the name directly from application.caller, but by using the myBTN
variable, you can get other stuff, too:

msgbox mybtn.topleftcell.address

for instance.

Tsjaikovski wrote:

I got a the following error on line 1
set myBTN = activesheet(application.caller)

"Object doesn't support this property or method"

Do I have to referene the application.caller somewhere?

Object doesn't support this property or method

"Dave Peterson" wrote:

these are buttons from the forms toolbar?

If you have a macro assigned to that button:

dim myBTN as Button
set myBTN = activesheet(application.caller)
msgbox mybtn.name & "- or - " & application.caller



Agamemnon wrote:

Hi

I have create a macro that put some buttons on a sheet.
As the buttons are created automatically I don't know what names they have.
So I would like to know how I can retrieve eg. in Cell sheet1!A1 the name of
the button I click on?

Can somebody help me out on this one?

Thx


--

Dave Peterson


--

Dave Peterson


All times are GMT +1. The time now is 05:47 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com