Sub is short for Subroutine.
What is a subroutine in VBA? A subroutine is like a habit. Say the habit you're trying to learn is to put away things, but you don't do it. After practicing it your brain does it without thinking. This is like a subroutine a routine thing to do in your subconscious. To start the subroutine we use the following terms: which all means the same thing. The subroutine does it's work. A subroutine is a piece of programming that does a task for you. Any time you record a macro you create a new subroutine. Subroutines are a way of writing the code once and reusing it. For example here is a subroutine to Create a Sheet. Once I get this working, any time I want to create a sheet, I can just "call" the subroutine to do the work of creating a sheet.
Examples of things that are like subroutines Why use Subroutines? Example of a subroutine Sub CalculateTax()
Details
Some things similar to a subroutine are: which we'll learn more about in later lessons. |