Calling a subroutine

During program development it’s important to notice which of its parts can be reused and, based on that fact, should create subroutines that will be called within the main program. Subroutines can be functions and procedures. We use the functions by specifying the variable name, followed by equality sign, and then the name of the function with the arguments. We invoke the procedures using the Call command, after which we specify the procedure name with the arguments.

First VBA program

When you create an Excel macro, it automatically defines a new subroutine, which is actually a program that runs after the specified action. You can also create subroutines independently which could be called from other programs, or run in the manner described below. This text will show how a simple code is written and how it is then linked to the objects that are used to launch it.