MS-Excel / General Formatting

Introducing macros

Macros are programmed procedures written in VBA language and are the same whether you record them or write them directly.

When you create a macro, you must choose a storage workbook. Macros are stored in three places: in the workbook in which you create them, in a new workbook, and in the Personal Macro Workbook.

  • This Workbook.
    If you store a macro in This Workbook (the workbook in which the macro is created), it is available to all open workbooks as long as the workbook in which the macro is stored is open. This is a good option if you want to send a workbook and its associated macros to another user, because the macros stored in the workbook go along with the workbook file.
  • New Workbook.
    If you store a macro in a New Workbook, Excel creates a new, unsaved workbook and stores the macro there regardless of which workbook you record the macro in. You must save the new workbook to save the macro, and (like the This Workbook option) the macro is only available when the new workbook is open.
  • Personal Macro Workbook.
    If you store a macro in the Personal Macro Workbook (nearly always my choice), the macro is available all the time to any workbook you have open. The Personal Macro Workbook is a file named PERSONAL.XLSM (which is created the first time you store a macro there), which is saved in the XLSTART folder in your Microsoft folders, and is hidden. Every time you store another macro in the Personal Macro Workbook, the macro is added to the existing Personal Macro Workbook. The Personal Macro Workbook opens whenever you start Excel, but you won't see it unless you deliberately unhide it. These macros are available to any open workbook, but only in your copy of Excel, and they don't travel with other workbooks.

Before we discuss recording and writing macros, you need to add the Developer tab to the Ribbon. In next section we will discuss on Developer tab.

[Previous] [Contents] [Next]