What is the syntax to call a local procedure?

Call <procedure name>
'example
Call loadSheet

Sub loadSheet()
    'code here
End Sub

 

Advertisements

What is the syntax to call procedures from another module?

Call <module name>.<sub procedure's name>
#example - project has a userform, and a module called Commands
Private Sub btnRefresh_Click() 'located in a userform
 Call Commands.output
End Sub


Sub output() 'located in Commands module
     MsgBox "This code is in a separate module"
End Sub

 

What is the syntax to declare procedures?

Private Function <your name> ()
   ‘your code here
   ‘callable only by procedures in the same module
End Function


Public Function <your name> ()
   ‘callable from any procedure
End Function

 
Private Sub <your name> ()
   ‘callable only by procedures in the same module
   ‘cannot be called from Macros dialog box
End Sub

 
Public Sub <your name> ()
   ‘callable from any procedure of any module
   ‘can run procedure from Macros dialog box
End Sub