eHow launches Android app: Get the best of eHow on the go.

How To

How to Develop Macros for Microsoft Excel

Contributor
By Launie Sorrels
eHow Contributing Writer
(0 Ratings)
Microsoft Excel
Microsoft Excel
Till Zoltan: flickr.com, Launie Sorrels

Recording macros has not changed much through the multiple Microsoft Excel versions, just how to initiate them. An Excel macro allows the user to perform a sequence of events and capture them identically on a macro recorder. Advanced users can code the macros line by line, and for very difficult functions, this is a necessity. However, for most users the macro recorder will do the job.

Difficulty: Easy
Instructions

    Create the First Macro

  1. Step 1
    Blank Workbook
     
    Blank Workbook

    Open Microsoft Excel 2007.

  2. Step 2
    Developer Tab
     
    Developer Tab

    Click the "Developer" tab.

  3. Step 3
    Recoed Macro
     
    Recoed Macro

    Click the "Record Macros" selection in the "Code" section. A "Record Macro" window will open. Under "Macro Name" type "TestMacro1." Macro names cannot contain spaces. Leave the rest of the information blank for this exercise. Click the "OK" button. Every keystroke will now be recorded into your macro. We are going to create a very simple macro as an example.

  4. Step 4
    Numbers Added
     
    Numbers Added

    Place the following numbers (1, 2, 3, and 4) into cells A1, A2, A3 and A4, respectively. Click the "Stop Recording" selection. You have created your first macro. We have now decided that we want these particular numbers to be shown as currency values.

  5. Create a second macro

  6. Step 1
    Cells Highlighted
     
    Cells Highlighted

    Click the "Record Macros" selection and name this macro "TestMacro2." Click the "OK" button to start the recording. Highlight cells A1 through A4.

  7. Step 2
    Format Cells...
     
    Format Cells...

    Right-click the selected cells and select "Format cells..."

  8. Step 3
    Format Cells to Currency
     
    Format Cells to Currency

    Change the Category to "Currency." Click the "OK" button.

  9. Step 4
    Stop Recording
     
    Stop Recording

    Click the "Stop Recording" selection. Now we want to add the values together.

  10. Create a third macro

  11. Step 1
    Select cell A6
     
    Select cell A6

    Click the "Record Macros" selection and name this macro "TestMacro3." Click the "OK" button to start the recording. Select cell A6.

  12. Step 2
    Add mathematical function
     
    Add mathematical function

    Type the following into the A6 cell: =A1+A2+A3+A4

  13. Step 3
    Stop Recording
     
    Stop Recording

    Press the "Enter" key. Click the "Stop Recording" selection.

  14. Running the macros

  15. Step 1
    Click to Sheet2
     
    Click to Sheet2

    Change the sheet selection to "Sheet2." Click the "Macros" icon. The "Macro" window will open.

  16. Step 2
    Run Macro window
     
    Run Macro window

    Select "TestMacro1" and press the "Run" button. You will see that your numbers have appeared on the sheet. Do the same for the other two macros you have created.

  17. Step 3

    Notice that the final version is an exact duplicate of what you created on "Sheet1." These three macros have showed you how to copy text, format cells and how to perform mathematical functions.

Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

eHow Computers
eHow_eHow Technology and Electronics