There is no built-in way to determine what procedure called
another. The only way would be to create a public variable, put
the caller's name in that variable, and read that variable in the
routine.
[in module1]
Public WhoCalled As New Collection
Sub AAA()
WhoCalled.Add "AAA"
' more code
End Sub
[in ThisWorkbook]
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Dim CalledBy As String
CalledBy = WhoCalled(WhoCalled.Count)
Select Case CalledBy
Case "AAA"
' do something
Case "BBB"
' do something else
Case ....
End Select
End Sub
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
"Sunil" wrote in message
...
When i run a macro that changes a cell the code below is run.
What i need to know is which procedure caused the code below to
be called.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
which macro procedure has called this routine ?
....run code depending on which procedure has called this sub
routine
End sub