Monday, June 20, 2005


Rule 12: The macro recorder produces bad code

The macro recorder produces bad code. Cut and paste, select / selection has been covered. It does other things too that aren't particularly good.

For example, it doesn't know about named ranges. As such it uses A1 style references all the time.

These should be cleaned up.

The code is very much a stream of conciousness type of approach to coding. Its much better to put some structure to the code.

Break the macro down into subroutines.

Rename the MacroN name of the recording to something that makes sense.

Remove the select / selection from the code

Remove the copy / paste constructs.

Think about any loops that make the code easier.

What about variables? Should things be declared as variables?
Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?

Subscribe to Posts [Atom]