ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   after click a button(commandbutton), getting the button name (https://www.excelbanter.com/excel-programming/406187-after-click-button-commandbutton-getting-button-name.html)

x taol

after click a button(commandbutton), getting the button name
 

Dim btn As MSForms.CommandButton

A sheet has a commandbutton.
what i want to, I click the button, getting the button name.
msgbox "this button name is " & xxx






*** Sent via Developersdex http://www.developersdex.com ***

RyanH

after click a button(commandbutton), getting the button name
 
You just need to use the caption property of the command button.

MsgBox "this button name is " & btn.Caption

"x taol" wrote:


Dim btn As MSForms.CommandButton

A sheet has a commandbutton.
what i want to, I click the button, getting the button name.
msgbox "this button name is " & xxx






*** Sent via Developersdex http://www.developersdex.com ***


x taol

after click a button(commandbutton), getting the button name
 


RyanH!
Surely, I already know it.
I want to know caption of the command button, when I click the button
the moment
namely,,,,,
1.click the button
2.It seems the name of the button in the message box.

*** Sent via Developersdex http://www.developersdex.com ***

Ker_01

after click a button(commandbutton), getting the button name
 
If you need the whole sub, this should give you a starting point. Be sure to
change the CommandButton1 if you are using this with a button of a different
name.

Private Sub CommandButton1_Click()
MsgBox CommandButton1.Caption
MsgBox CommandButton1.Name
End Sub

"x taol" wrote in message
...


RyanH!
Surely, I already know it.
I want to know caption of the command button, when I click the button
the moment
namely,,,,,
1.click the button
2.It seems the name of the button in the message box.

*** Sent via Developersdex http://www.developersdex.com ***





All times are GMT +1. The time now is 11:26 AM.

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