VB and VBA Users Source Code: Returning the name of the CommandBarButton that was clicked
[
Home
|
Contents
|
Search
|
Reply
| Previous | Next ]
VB/VBA Source Code
Returning the name of the CommandBarButton that was clicked
By:
Andrew Baker
Email (spam proof):
Email the originator of this post
Date:
Friday, July 09, 2004
Hits:
1843
Category:
VBA (Visual Basic for Applications)
Article:
The function below returns the name of the Excel (office) CommandBarButton which called the current macro. 'Purpose : Returns the name of CommandBarButton that was clicked 'Inputs : N/A 'Outputs : If a CommandBarButton started the called macro this will return it's name, ' else it will return an empty string. 'Author : Andrew Baker 'Date : 25/03/2000 'Notes : Function ButtonClicked() As String On Error GoTo ErrFailed 'The button name is the second item in the caller stack ButtonClicked = Application.Caller(2) Exit Function ErrFailed: 'Didn't find a button ButtonClicked = "" End Function
Terms and Conditions
Support this site
Download a trial version of the Excel Workbook Rebuilder