You are correct, I just suggested a work-around. You are correct though, it doesn't answer the request as specified. I did not read the initial request carefully enough.
I think the work-around would be simpler, but you could create a global boolean variable that you could toggle to true before calling the macro from a different procedure. Like:
Global Called As Boolean
Public Sub multibeep(numbeeps As Long)
For i = 1 To numbeeps
MsgBox i
Next i
If Called = True Then
MsgBox "Called Remotely"
Else
MsgBox "Called Directly"
End If
End Sub
Public Sub testremote()
Called = True
multibeep 2
End Sub
This however still wouldn't work if you want numbeeps to be an argument. You could also make that a global variable, but then you are getting very complicated, and I think the work-around is much simpler.
Global Called As Boolean
Global numbeeps As Long
Public Sub multibeep()
If numbeeps = 0 Then
numbeeps = Int(InputBox("How many beeps?", "?")) 'Or other source such as worksheet cell.
End If
For i = 1 To numbeeps
MsgBox i
Next i
If Called = True Then
MsgBox "Called Remotely"
Else
MsgBox "Called Directly"
End If
End Sub
Public Sub testremote()
numbeeps = 2
Called = True
multibeep
numbeeps = 0
Called = False
End Sub
Does that seem reasonable?
Bookmarks