Sei sulla pagina 1di 3

MACROS

Definition: An Excel macro is a set of instructions that can be triggered by a keyboard shortcut, toolbar button or an icon in a spreadsheet. Macros are used to eliminate the need to repeat the steps of common tasks over and over. Tasks such as: adding or removing rows and columns protecting or unprotecting worksheets selecting a range of cells adding the current date to a spreadsheet

n Excel, macros are written in !isual "asic for Applications #!"A$. %or those who cannot write !"A code, Excel allows you to record a series of steps & using keyboard and mouse & that Excel then converts into !"A. Excel Macro Recorder

The easiest way to create a macro in Excel is to use the macro recorder. To do so, click Tools > Macros > Record New Macro from the menus to bring up the 'ecord Macro dialog box. The Macro Recorder dialogue box

There are ( options to complete in this dialog box: ). *ame + give your macro a descriptive name. ,. -hortcut key & #optional$ fill in a letter in the available space. This will allow you to run the macro by holding down the .T'/ key and pressing the chosen letter on the keyboard. 0. -tore macro in + 1ptions: o the current workbook o The macro is available only in this file.

a new workbook This option opens a new Excel file. The macro is available only in this new file.

a personal macro workbook. This option creates a hidden file + 2ersonal.xls + which stores your macros and makes them available to you in all Excel files.

(. 3escription & #optional$ enter a description of the macro.

Recording the Macro

4hen finished setting your options in the Macro Recorder dialogue box in the previous step of this tutorial, click the 15 button to start the macro recorder. The Stop Recording toolbar should also appear on screen. The macro recorder records all keystrokes and clicks of the mouse. .reate your macro by: manually going though all the necessary steps.

4hen finished, click the stop button #small blue s6uare$ on the Stop Recording toolbar.

f the Stop Recording toolbar is not available, click Tools > Macros > Sto Recording from the menus to stop recording.

Running the !acro in Excel

To run a macro you have recorded: f you chose a shortcut key when creating the macro, hold down the CTR" key on the keyboard and press the shortcut key. 1therwise, ). .lick Tools 7 Macros 7 Macro from the menus to bring up the Macro dialogue box. ,. -elect a macro from the list of those available. 0. .lick the Run button.

Potrebbero piacerti anche