Prevent Overloaded variables

  • Thread starter Thread starter Jeff
  • Start date Start date
J

Jeff

Hi,

I have some variables declared at the top of the module, so they are used
throughout the program. But here is the problem, I can redeclare the
variable inside another sub procedure, how do I prevent this? This seems
like bad feature to have in excel.

I declared option explicit at the top.

Thanks for your help.
 
I use a naming convention so that variables declared at the top of a molule
as constants have a 'con' prefix. So if I have a constant named conFilePath
and I need to declare a file path string variable in another sub or
funcition, in the a sub or function I use a 'str' prefix to denote a string
variable.

That would eliminate conficting names at the module, and procedure level.
 
I think you should search VBA's help for: Understanding Scope and Visibility

Someday, you may appreciate the fact that you can do what you don't want to do
today.
 
Back
Top