Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
I have a few macros that are being edited. My question - is there a way to tell if a declared variable has been used in the "sub Marcro()" or if it was just declared (i.e. dim Variable3 as double) and not used. This would be useful because it would allow me to more easily delete unused variables and eliminate clutter. Thanks |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Since it's only a few macros, the easiest way would probably be to use
Find() with the variable name in the VBE, which has an option to look in the current procedure. If you require variable declaration (which you absolutely should) by using Option Explicit, you could also comment out the declaration of suspect variables, then compile - if the variables are used, it will generate a compile error, if not, you're free to delete the declaration. In article , Jeff wrote: Hi, I have a few macros that are being edited. My question - is there a way to tell if a declared variable has been used in the "sub Marcro()" or if it was just declared (i.e. dim Variable3 as double) and not used. This would be useful because it would allow me to more easily delete unused variables and eliminate clutter. Thanks |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
If the first line in the module is not OPTION EXPLICIT, enter it so that all
variables have to be declared before using them and do the following: Place an apostrophe at the beginning of the DIM statement to make the declaration a comment Recompile the code by clicking DEBUG and selecting COMPILE VBA PROJECT. If it compiles OK the variable was not used. -- Kevin Backmann "Jeff" wrote: Hi, I have a few macros that are being edited. My question - is there a way to tell if a declared variable has been used in the "sub Marcro()" or if it was just declared (i.e. dim Variable3 as double) and not used. This would be useful because it would allow me to more easily delete unused variables and eliminate clutter. Thanks |
#4
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Download MZ-Tools, it has a facility to analyze a project and it tells you
that. It is free. -- --- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "Jeff" wrote in message ... Hi, I have a few macros that are being edited. My question - is there a way to tell if a declared variable has been used in the "sub Marcro()" or if it was just declared (i.e. dim Variable3 as double) and not used. This would be useful because it would allow me to more easily delete unused variables and eliminate clutter. Thanks |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
type declaration characters | Excel Discussion (Misc queries) | |||
type declaration characters | Excel Discussion (Misc queries) | |||
Macro / Compile Error / Duplicate Declaration | Excel Worksheet Functions | |||
Last rites declaration of Ioannes Paulus PP. II (Karol Wojtyla) | Charts and Charting in Excel | |||
Use DocProps in a change declaration | Excel Worksheet Functions |