View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bernie Deitrick[_2_] Bernie Deitrick[_2_] is offline
external usenet poster
 
Posts: 176
Default Macro name as constant

Jamie,

It's easier to just use declared constants:

Sub TestMacro()
Const myName As String = "TestMacro"
MsgBox "The macro " & myName & " has worked.", _
vbOKOnly, "Message from " & myName
End Sub

HTH,
Bernie


"Jamie Martin" wrote in message
...
Can I use a constant in declaring the name of a Sub procedure?

Better yet
(so my Sub procedures can continue to have descriptive names), can a
procedure output its own name as a string?

I ask because I have many verbose message boxes that refer to the

names of
the macros that a user has invoked or that the invoked macro has

called, and
I want to make sure I get the names of the macros right every time.