Excel’s macro recording tool is a very powerful feature. It allows you to record the actions you perform in Excel and replay then as much as you like. It’s also a great way to learn how to code with VBA (visual basic for applications) as the macro recorder will write the VBA code for you for all the actions you record.

 

Step 1: Enable the Developer tab in the ribbon.

 

By default Excel’s developer tab is hidden and you will need to go into the options to enable it.

 

Step-001-How-To-Record-And-Run-Your-First-Macro How To Record And Run Your First Macro

 

Enable the Developer tab.

  1. Go to the File tab.
  2. Click on Options.
  3. In the Excel Options window, click the Customize Ribbon section.
  4. Make sure Developer is checked.
  5. Press the OK button.

 

Step 2: Record your first macro.

 

Now the developer tab should appear in your ribbon and you’re ready to record your first macro. For this example we’re going to record a very simple but useful macro that auto adjusts the column width in the current sheet so that data in the sheet is visible and not truncated from view.

 

Step-002-How-To-Record-And-Run-Your-First-Macro How To Record And Run Your First Macro

 

Start recording the macro.

  1. Go to the Developer tab.
  2. In the Code section, hit the Record Macro button.
  3. Name your macro to something like AutoAdjustWidth.
  4. For the Store macro in option, select the default This Workbook setting if you only want to use this macro in the current workbook. Select Personal Macro Workbook if you’d like to be able to use this macro in all your workbooks.
  5. Press the OK button.

 

Step-003-How-To-Record-And-Run-Your-First-Macro How To Record And Run Your First Macro

 

Now that we have started the macro recorder, we can perform our actions that will be recorded.

  1. Press the Select All sheet icon located in the upper left hand corner of the worksheet.
  2. Hover your mouse over the column separator between the first and second column until it changes to a vertical black bar with two arrows coming out horizontally. Now do a double left click with the mouse. The columns should expand to the right amount so that all data entered in the sheet is visible.
  3. Press the Stop Recording button.

 

Step-004-How-To-Record-And-Run-Your-First-Macro How To Record And Run Your First Macro

 

Now if we open the VBE (visual basic editor) we will see the code that has been written for us by the macro recorder.

  1. Go to the Developer tab.
  2. In the Code section press the Visual Basic button. You can also press Alt + F11 to open the VBE.
  3. The code should appear in Module1.
  4. You can view the code that has been recorded here.

 

Step 3: Run your macro.

 

Step-005-How-To-Record-And-Run-Your-First-Macro How To Record And Run Your First Macro

 

If you want to run this macro again then you

  1. Go to the Developer tab.
  2. In the Code section, press the Macros button.
  3. In the Macro window select the macro you want to run.
  4. Press the Run button.

 

There’s no limit to the length of macro you record so they can become pretty big time savers if you find you are always performing the same tasks over and over again.