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 a procedure?

  • Grouped statements that relate to a specific task
  • Used for complex tasks that can be further broken down into smaller tasks
  • Two types of procedures: sub and function
Function <name>(<parameters>)
‘callable from anywhere in program
‘can return values
‘put function declarations in a module sheet
End Function
Sub <name>(<parameters>)
‘do not return values
End Sub