Stop searching. Start learning and developing your excel skills.
Macro
VBA
Formula
Function
Shortcut
Tricks

» » VBA Sub and Function Procedure

VBA Sub and Function Procedure

August 09, 2017 |
Definition from Microsoft:

A Sub procedure is a series of Visual Basic statements enclosed by the Sub and End Sub statements. The Sub procedure performs a task and then returns control to the calling code, but it does not return a value to the calling code.

A Function procedure is a series of Visual Basic statements enclosed by the Function and End Function statements. The Function procedure performs a task and then returns control to the calling code. When it returns control, it also returns a value to the calling code.

Sub is a short form of subroutines. It means a set of instructions designed to perform a frequently used operation within a program (google definition).


Example:

If you wish to perform a task that returns a result (example sum a set of numbers), you will generally use a Function procedure.

If you just need a set of actions to be carried out (example open, vlookup, format, etc), you might choose to use a Sub procedure.

No comments:

Post a Comment