Scoping variables
In this recipe, we will be working with the range of effect, or scope, of variables.
Whenever you declare a variable in a module, you would expect that variable to at least have an effect within that module. You can also say you would expect your macro to work on the sheet where you created the macro, at the very least.
What has not been said before is that a workbook can accommodate any number of VBA modules and a module can accommodate any number of Sub and Function procedures. This information is merely academic.
This knowledge becomes important when you have more than one procedure in a module, several modules in the workbook, and more than just one worksheet in a workbook. The questions are: which macro will have an effect in which module, and is it possible for one macro to work in more than one module, or even in several sheets?
All depending on what you want to achieve with your macro, you can set the scope of a procedure with certain keywords...