Hi,
I use Excel macros extensively, and have recently started migrating blocks of code into my personal.xlsb workbook and adding references to my projects. I am self-taught, so there are some practices I use that are probably not within acceptable standards, and this idea may be one of those.
In the process of editing and moving re-used code blocks to minimize reptition of code, I see that over the last few years I have been using the same or similar names for variables at the module level. For example, I work in the financial industry and use variables with names like "brName" and "brID" for "branch name" and "branch ID" almost all the time. They are commonly declared at the top of a module so that they can be passed into the various procedures.
I guess my question is less of a technical nature and more philosophical.
Would it be of any advantage for me to place the Dim statements in my personal workbook (and thereby doing it only once) as Public statements? Does anyone see or know a reason why I should not do it this way? Or is this one of those things considered bad form or practice for programming and be avoided at all costs? I know I would have to clear all variables in the beginning of any code I write in the future, but I figure that that would be a kind of way to "declare" the variables used in the module/procedure.
I'm just not sure if this is a good idea or practice and would like some other thoughts before I commit.
TIA,
Al
I use Excel macros extensively, and have recently started migrating blocks of code into my personal.xlsb workbook and adding references to my projects. I am self-taught, so there are some practices I use that are probably not within acceptable standards, and this idea may be one of those.
In the process of editing and moving re-used code blocks to minimize reptition of code, I see that over the last few years I have been using the same or similar names for variables at the module level. For example, I work in the financial industry and use variables with names like "brName" and "brID" for "branch name" and "branch ID" almost all the time. They are commonly declared at the top of a module so that they can be passed into the various procedures.
I guess my question is less of a technical nature and more philosophical.
Would it be of any advantage for me to place the Dim statements in my personal workbook (and thereby doing it only once) as Public statements? Does anyone see or know a reason why I should not do it this way? Or is this one of those things considered bad form or practice for programming and be avoided at all costs? I know I would have to clear all variables in the beginning of any code I write in the future, but I figure that that would be a kind of way to "declare" the variables used in the module/procedure.
I'm just not sure if this is a good idea or practice and would like some other thoughts before I commit.
TIA,
Al