Presentation is loading. Please wait.

Presentation is loading. Please wait.

Macros Excel built-in functions are great but limited Macros are a means for the user to define new functions A macro is a single command that automates.

Similar presentations


Presentation on theme: "Macros Excel built-in functions are great but limited Macros are a means for the user to define new functions A macro is a single command that automates."— Presentation transcript:

1 Macros Excel built-in functions are great but limited Macros are a means for the user to define new functions A macro is a single command that automates some aspect of Excel so that you can work more efficiently with fewer errors One key or button replaces a series of actions Useful if there is a sequence of actions that occurs frequently Can be applied to an entire row or column There are two ways to create them Recorded macros (easier)‏ Writing macros using VBA (more powerful!)‏

2 Recorded Macros While working with recorded macros and using Visual Basic within Excel, it is helpful to have the Developer ribbon available This ribbon might not be currently visible on the main menu To add the Developer ribbon to the menu, click the Office button and then click Excel Options. In the Popular category, under “Top options for working with Excel”, check the “Show Developer tab in the Ribbon” check box and click OK. To record a macro Click on developer ribbon Within the Code group, choose Record Macro You will get a pop-up window asking for a name, description, and control key for the macro Give your macro a meaningful name, a short description, and assign it to a key for future execution

3 Recorded Macros Start by positioning the cursor where you want it to be before the macro begins. Once you begin recording, everything you do will be recorded, so you don’t want to position your cursor after you start recording, unless you want the macro to begin in the same cell every time it is executed After you click on ok, the window will disappear and everything you do now will be recorded as part of the macro until you click on Stop Recording in the Code group Now enter the keystrokes you want as part of your macro, pressing the stop recording button when finished When you save an Excel sheet containing a macro, make sure you save as it.xlsm – i.e. macro enabled workbook

4 Recorded Macros There is an icon in the Code group that allows you to set the addressing mode to relative addressing. If you don’t change this, the default mode for recorded macros is absolute referencing Macros designed with absolute addresses always use the same cells on a worksheet, in other words, if you wanted a macro that would print your name in cell A10 and your e- mail address in B10, you would use absolute addressing You could write the same macro with relative addressing to print your name in whatever cell you position the cursor in, with your e-mail address right below it Relative addressing is much more flexible, and what you will want most of the time, so make sure this button is pressed before you start recording your macro when you wish to have your macro use relative addressing

5 Recorded Macros Past Due Accounting Example Clear Sheet and save Record, Select cells, clear and save Fill penalty column (if overdue=yes) 10% if amount >$120 5% otherwise Check recorded macros Developer  Macros  Click on desired  Edit Complicated to read What is FormulaR1C1? Only good for small things Adding prerecorded text Executing simple formulas

6 Writing Macros using VBA Much closer to what we did in VB Simpler statements Begin as if you’re recording a macro and stop recording After giving it a name and control character Go and edit the macro Past Due Accounting.xls The ActiveCell and ActiveCell.offset(x,y)‏


Download ppt "Macros Excel built-in functions are great but limited Macros are a means for the user to define new functions A macro is a single command that automates."

Similar presentations


Ads by Google