Pages

Monday, 30 June 2014

How to Write a Simple Macro in Microsoft Excel

Method 1 of 2: Excel 2007 and 2010

  1. 1
    Click the Developer tab on the Ribbon at the top of the screen. If the tab is not showing up on your screen, you can add it as follows:
    • For Excel 2010: click the File Tab then select options. On the left hand side of the Excel options dialog box, click Customize Ribbon. Then, on the right hand side box select Developer.
      Write a Simple Macro in Microsoft Excel Step 1Bullet1.jpg
    • For Excel 2007: click the Microsoft Office button, then Excel Options. In the Popular category, under Top Options for Working with Excel, select Show Developer Tab in Ribbon.
      Write a Simple Macro in Microsoft Excel Step 1Bullet2.jpg
    Ad
  2. Write a Simple Macro in Microsoft Excel Step 2.jpg
    2
    Change the security settings. In Trust Centre, Under Macro Settings, click Enable All Macros, then click OK.
    • Note that this security setting is not ideal for basic use. When you've finished creating your macro, go back and un-click Enable All Macros.
  3. Write a Simple Macro in Microsoft Excel Step 3.jpg
    3
    Click Record Macro. You'll find it on the Developer tab under Code.
  4. Write a Simple Macro in Microsoft Excel Step 4.jpg
    4
    Name your macro. The first character of the name must be a letter; after that, you can use characters, numbers and underscores. Macro names cannot have spaces.
    • Don't use the same name for your macro as an existing cell reference.
  5. Write a Simple Macro in Microsoft Excel Step 5.jpg
    5
    Set a shortcut for your macro (optional). Type a letter in the Shortcut Key box. A lowercase letter will translate to CTRL + letter; an uppercase letter will be CTRL + SHIFT + letter.
  6. Write a Simple Macro in Microsoft Excel Step 6.jpg
    6
    Choose where to store your macro. In the Store Macro In list, select the workbook where you want to store the macro. If you want it to be available whenever you run Excel, select Personal Macro Workbook.
  7. Write a Simple Macro in Microsoft Excel Step 7.jpg
    7
    Describe your macro. Write this in the Description box.
  8. Write a Simple Macro in Microsoft Excel Step 8.jpg
    8
    Click OK to start recording your macro.
  9. Write a Simple Macro in Microsoft Excel Step 9.jpg
    9
    Perform the actions you want the macro to record.
  10. Write a Simple Macro in Microsoft Excel Step 10.jpg
    10
    Stop recording. Go to the Developer tab, click Code, then click Stop Recording.

Method 2 of 2: Excel 2003

  1. 1
    Change the security level. Switch the security level from Medium to Low.
    • Click Tools -> Options -> Security.
      Write a Simple Macro in Microsoft Excel Step 11Bullet1.jpg
    • Click Macro Security.
      Write a Simple Macro in Microsoft Excel Step 11Bullet2.jpg
    • Select Security Level. Select Low.
      Write a Simple Macro in Microsoft Excel Step 11Bullet3.jpg
  2. Write a Simple Macro in Microsoft Excel Step 12.jpg
    2
    Start recording your macro. Navigate to Tools -> Macro -> Record New Macro.
  3. Write a Simple Macro in Microsoft Excel Step 13.jpg
    3
    Name your macro. The character of the name must be a letter; after that, you can use symbols, numbers or underscores. No spaces are allowed.
    • Don't use the same name for your macro as an existing cell reference.
  4. Write a Simple Macro in Microsoft Excel Step 14.jpg
    4
    Code a shortcut for your macro (optional). Enter a letter in the Shortcut Key box. A lowercase letter will make the shortcut CTRL + letter; uppercase will be CTRL + SHIFT + letter.
  5. Write a Simple Macro in Microsoft Excel Step 15.jpg
    5
    Choose where to store your macro. In the Store Macro box, select a location for your macro. Click Personal Macro Workbook if you want it to be available whenever you open Excel.
  6. Write a Simple Macro in Microsoft Excel Step 16.jpg
    6
    Write a description of your macro.
    • When you're done, click OK.
      Write a Simple Macro in Microsoft Excel Step 16Bullet1.jpg
  7. Write a Simple Macro in Microsoft Excel Step 17.jpg
    7
    Record your macro. Remember, Record Macro is still on. Carry out the actions that you want Excel to record as your macro.
  8. Write a Simple Macro in Microsoft Excel Step 18.jpg
    8
    Click Stop Recording. You can find this option on the Stop Recording toolbar.

No comments: