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

  • Thread starter Thread starter x taol
  • Start date Start date
X

x taol

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
 
You just need to use the caption property of the command button.

MsgBox "this button name is " & btn.Caption
 
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top