excel vba - macro calling anoter macro ?

Copper Contributor

excel vba - how can I from macro calling anoter macro ?

1 Reply

@ariellavy The simplest way is to just type the name in your routine. Below are two examples. The first example (#1 and #2) show how to call one from another. The second example (#3 and #4) show how to call one and also pass a parameter to another routine.

 

Sub Routine1()
    MsgBox "Hello, I'm #1"
    Routine2
End Sub


Sub Routine2()
    MsgBox "Hello, I'm #2"
End Sub

 

Sub Routine3()
    Routine4 "Hello, I'm originally from #3, but am now in #4!"
End Sub


Sub Routine4(ByVal Message As String)
    MsgBox Message
End Sub

 

HTH