QP School

Full Version: Functions in VBA
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Description:

Functions are blocks of code that perform specific tasks and return a value to the calling code. 
They are called by their name and can be used in expressions.

Example:

Function AddNumbers(a As Integer, b As Integer) As Integer
    AddNumbers = a + b
End Function

Sub ExampleFunction()
    MsgBox "The sum is: " & AddNumbers(5, 3)
End Sub