Home / MS-Excel / General Formatting

Writing Your Own Macros

Letting VBA do all the work by recording your macros is an easy way to automate tasks, and it's a technique you'll use often. However, to get the most out of VBA you need to do some full-fledged programming, which means writing your own macros, either from scratch or by using a recorded macro as a starting point.

Why go to all that trouble? Here are just a few of the advantages you gain by doing this:

  • If you make a mistake while recording a macro, particularly one that requires a large number of steps, you can make a simple edit to the macro's VBA code to fix the mistake rather than re-record the whole thing from scratch.
  • You get full control over each macro, which means you ensure that your macros do exactly what you need them to do.
  • You can take advantage of the hidden power of VBA to manipulate the Office programs and to perform some impressive programming feats that are simply not available via the recording process.

To help you realize these advantages and many more, this tutorial introduces you to the basics of writing simple procedures and functions, as well as how to get around in the Visual Basic Editor, which is the tool that VBA provides for writing macros by hand.