Are variables in a VBA procedure available to other VBA procedures What if the procedure is in a different module Or in a different workbook

You're talking about a variable's scope. There are three levels of scope: local, module, and public. Local variables have the narrowest scope and are declared within a procedure. A local variable is visible only to the procedure in which it was declared. Module-level variables are declared at the top of a module, prior to the first procedure. Module-level variables are visible to all procedures in the module.

Public variables have the broadest scope, and they are declared by using the Public keyword.

0 0

Post a comment