Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]() 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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Small revision.....
Change CalledBy = WhoCalled(WhoCalled.Count) ' to CalledBy = WhoCalled(WhoCalled.Count) WhoCalled.Remove WhoCalled.Count -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting, LLC www.cpearson.com "Chip Pearson" wrote in message ... 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Private Sub - Called from Userform | Excel Discussion (Misc queries) | |||
How can Oracle DB Stored procedure be called in MS Excel? | Excel Discussion (Misc queries) | |||
re : Possible to run private sub macros by writing another private | Excel Programming | |||
Opening a UserForm causes a crash in the Exit procedure (Which is never called) | Excel Programming | |||
Public subroutine called from a private sub | Excel Programming |