3. Learn VBA - SUBS and FUNCTIONS explained

Nick's picture

Now we're going to learn what VBA SUBS and FUNCTIONS are.

A SUB is a piece of code that runs something
A FUNCTION is a piece of code that returns something

Now lets see it in action with a real life example:

Your wife asks you the time.
You look at your watch
You tell her the time.

What would this look like in code ?

- If we attach the Sub TellWifeTheTime to a button and then press it, what would happen ?
- the Sub TellWifeTheTime goes away and gets the time from the function WhatTimeIsIt, and then displays the time in a message box

Download practise sheet, and press the button

Subs and Functions explained in this training Video: