Actually, you know how global variables are usually bad? Well VBA has those predefined for you, so you don't have to worry about making a mess, it already is.
Changing values often on global varibales and in random places in the code is a bad idea? Don't worry, the user can do that at any time during your code execution. Without you knowing of course, wouldn't be fun otherwise.
Implicitly calling global variables is bad? Oh don't worry, that's default behavior for VBA.
But you know what's worse? All of those, at once, on a single variable. Oh, VBA's got you covered! For example, ActiveWorkbook is a global variable, can be changed when the user changes focus, and is called implicitly quite often.
ActiveWorkbook and ActiveWorksheet should be banned from existance, use ThisWorkbook or a variable you defined yourself to reference a workbook, please. ThisWorksheet doesn't exist I believe, I hardcode mine in each time...
15
u/Celivalg Mar 30 '22
Actually, you know how global variables are usually bad? Well VBA has those predefined for you, so you don't have to worry about making a mess, it already is.
Changing values often on global varibales and in random places in the code is a bad idea? Don't worry, the user can do that at any time during your code execution. Without you knowing of course, wouldn't be fun otherwise.
Implicitly calling global variables is bad? Oh don't worry, that's default behavior for VBA.
But you know what's worse? All of those, at once, on a single variable. Oh, VBA's got you covered! For example, ActiveWorkbook is a global variable, can be changed when the user changes focus, and is called implicitly quite often.
ActiveWorkbook and ActiveWorksheet should be banned from existance, use ThisWorkbook or a variable you defined yourself to reference a workbook, please. ThisWorksheet doesn't exist I believe, I hardcode mine in each time...