Procedure

A procedure performs a specific task.

Example

Sub FormatReport()

    Range(“A1:H1”).Font.Bold = True

    Range(“A1:H1”).Borders.LineStyle = xlContinuous

End Sub

Run:

FormatReport

Function

A VBA function returns a value.

Function AddGST(Amount As Double) As Double

    AddGST = Amount * 1.18

End Function

Then the function can be used from VBA or, when defined appropriately in a standard module, from a worksheet:

=AddGST(B2)

Practice

Create:

  1. A procedure to format a report.
  2. A function that calculates 18% GST-inclusive amount.