View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
IanKR IanKR is offline
external usenet poster
 
Posts: 97
Default Tell whether or not Sub B was called by Sub A?

'/-----------------------------------/
Sub A()
Dim SubBCalledFromSubA As Boolean

'first reset Boolean, just in case
SubBCalledFromSubA = False

' .....

SubBCalledFromSubA = True
Call B(SubBCalledFromSubA)
' ....

'reset Boolean
SubBCalledFromSubA = False
End Sub

'/-----------------------------------/
Sub B(Optional blnCheck)
If IsMissing(blnCheck) Then blnCheck = True

If blnCheck = True Then
'code here
MsgBox "It's True!"
End If

If blnCheck = False Then
'some other code here
MsgBox "It's False :O<"
End If
End Sub
'/-----------------------------------/

--
Hope this helps.
If it does, please click the Yes button.
Thanks in advance for your feedback.
Gary Brown


Many thanks, Gary - "Yes"!