Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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. |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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. -- Kevin Backmann "Jeff" wrote: 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. |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
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. Jeff wrote: 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. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Too Many Variables | Excel Worksheet Functions | |||
HOW CAN I PREVENT EXCEL FILES FROM BEING DELETED OR PREVENT TRASH | Excel Discussion (Misc queries) | |||
How do I add variables | Excel Discussion (Misc queries) | |||
Variables in VBA | Excel Discussion (Misc queries) | |||
Too many variables? | Excel Worksheet Functions |