Finding unused macros

R

Richard H Knoff

I have a workbook containing several VBA macros that aren't actually
in use - but I want to be sure that they're not needed before I
delete them. Is there a way to identify macros that are and are not
referenced in the workbook - that is, in the sheets or in the VBA
modules?

Richard
 
M

Myrna Larson

Just "comment" them out by putting apostrophe's at the beginning of each line.
Then Debug/Compile the workbook. If they are called by other procedures,
you'll get errors when compiling. This is quite easy if you have buttons for
Comment Block and Uncomment Block added to your toolbar.

Another way is to use Edit/Find to search for the procedure name. If it's
found only in the procedure itselt, it's never called.

For functions, you also have to force a recalculation of the worksheets
(CTRL+ALT+F9) and look for errors (Edit/Goto/Special and select errors).
 
S

SidBord

There's probably a better way, but here's what I do:
Rename each macro one at a time (I put an X at the end of
the name), then click DEBUG->COMPILE TEST. The compiler
will let you know if the renamed macro can't be found. If
it says nothing, then the macro isn't being used.
 
Top