Creating a new macro

There are two ways of creating an Excel VBA macro. They are: Record operations performed on worksheet;

Type the macro source code in directly; that is using the VBA language. The remainder of this chapter will focus on the first method. Chapter 3 will explore the VBA method.

Preparation is essential before recording a new macro. First, it should be noted that macros could involve many steps. These steps should be practised before recording the macro, because once the macro recorder begins, all the actions are recorded - mistakes as well. The macro recorder does not however, record the time taken between steps, so take your time to make sure that you don't have to repeat the process. Second, thought must be given to the environment for which the macro will operate. For example, will the macro be used for a specific document or a group of documents? If you are likely to open the macro with a specific workbook, then open the workbook. Otherwise, you might need to think about where it is likely to be used before recording a new macro. When these preparatory steps have been completed, the user can then proceed with recording.

You will need to do the following to record a new macro:

1 Set up the starting conditions for the macro, such as opening the workbook, and anything else that might be necessary. For example, it may be necessary to select a specific worksheet, or range of cells, etc.

0 0

Post a comment