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.
Stop searching. Start learning and developing your excel skills.
Other Excel Tutorials:

Record Macro
Click at Developer → Record Macro. Alternatively, you can click at Record Macro button. It is lo ...

VBA How To Use MsgBox
MsgBox is used to display a message in a dialog box, waits for the user to click a button, and retu ...

Why VBA?
1. Automation Do you have any report that you need to do on daily basis, weekly or monthly basis ...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment