Prevent Overloaded variables

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.
 
K

Kevin B

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.
 
D

Dave Peterson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top