Przemyslaw Remin
Przemyslaw Remin

Reputation: 6950

Get the name of currently executed macro in Excel VBA

How to get the currently executed macro name in Excel VBA?

Sub WhateverMacroName()
    MsgBox (GetTheNameOfCurrentlyExecutedMacro)
End Sub

Which should return WhateverMacroName

Upvotes: 0

Views: 1925

Answers (1)

Gary's Student
Gary's Student

Reputation: 96771

That which is not exposed must be remembered.

Define a Global variable and have each Sub setup the variable at entry. Thus a general error handler can determine a miscreant.

If you have a nested call structure (with subs calling subs), you will need to implement a stack.

Upvotes: 4

Related Questions