Excel VBATutorial                        Tutorial on Excel macros

 

Excel VBA Macros

Excel Macros Table of Contents

Excel Visual Basic Editor

Excel Macros Vocabulary

Excel Userforms

Excel Consulting

Excel Tutorial on Macros

Email to excel-vba.com

Here is a sample of what you will find in lesson 7 of the downloadable Tutorial on Excel macros

Lesson 7 on Excel macros (VBA):

The Macro Recorder in Excel 2007 to 2010 and 2014

Note: If you are using Excel 1997 to 2006 see lesson 7 here

IMPORTANT NOTE 1: There are no risks to your computer or to Excel in completing the exercises below. At any time if you feel uncomfortable just close Excel without saving the workbook and retry later.

IMPORTANT NOTE 2 (for Excel 2007 ONLY) : You can only complete the exercises below if you have installed VBA for Excel on your computer. If you do not have, click here.

One of the tools that makes the programming environment in Excel unique is the Excel Macro Recorder. When you start the macro recorder anything you do in Excel is recorded as a new macro. That makes the macro recorder the best VBA teacher and also a great assistant who will write a lot of the words and sentences that you need without a single typo. It will also be there when you do not remember something that you do not use often. Even after many years of programming you will still use the macro recorder daily not to learn anymore but to write code (VBA words and sentences).

With the Excel macro recorder you can not develop a macro that will damage Excel or your computer so try anything and learn.

In this lesson on line you will record a macro and run it.

Recording Your First New Macro:

Step 1: Print this page.

Step 2: Open Excel and a new workbook.

Step 3: Go to the "Developer" ribbon to click on  VBA macro recorder

Step 4: A small window appears titled "Record Macro". We will review its components in the downloadable tutorial. For now just click on "OK".  

Excel macros definition

When you do so the small window disappears and in the "Developer" ribbon VBA macro recorder  is replaced by VBA stop recording telling you that you are going in the right direction. The macro recorder is ON.

Step 5: In the sheet below (Sheet1) select cells B1 to B5, go to "Sheet2", select cell B6, come back to "Sheet1" and select cells D2 to D5.

Step 6: In the "Developer" ribbon click on VBA stop recording

Running your first recorded macro

Step 1: Select cell "A1" of "Sheet1".

Step 2: In the "Developer" ribbon click on Exvl macro button

Step 3: In the window that appears Macro1 is selected.

Excel run macro

Again we will forget about the components of this window because we will study them in the downloadable tutorial. For now, just click "Run".

Step 4: See how fast the macro runs. You do not even see Excel go to Sheet2 (but it does). At the end of the execution cells D2 to D5 are selected.

What took you around 5 seconds to do manually (step 5 of the first exercise) took Excel a fraction of a second. Excel can work much faster than you can. Welcome to the marvelous world of VBA for Excel (Macros).

You can repeat steps 1 to 4 of this second exercise as often as you like.

Looking at your first recorded macro

To complete this third exercise you must have studied lessons 1 to 4.

Go to the Visual Basic editor and you will see the following macro in the code window when you double click on Module 1 in the Project Window:

Sub Macro1()

' Macro1 Macro

    Range("B1:B5").Select
    Sheets("Sheet2").Select
    Range("B6").Select
    Sheets("Sheet1").Select
    Range("D2:D5").Select

End Sub

As you can see the macro recorder recorded your instructions in a language that Excel understands (VBA). You can now use VBA's written code to have Excel perform this task.

Never forget that the Excel macro recorder is your best teacher and will remain a great assistant for the rest of your VBA developer's life.


We hope you have enjoyed this introduction to lesson 7
for more on this topic and a complete course on Excel macros download the
Tutorial on Excel Macros


Next Lesson: Macros Help and Assistance

 

Excel Tutorial on Macros

Excel VBA Macros

Excel Macros Table of Contents

Excel Visual Basic Editor

Excel Macros Vocabulary

Excel Userforms

Excel Consulting

The following is for Excel 2007 to 2014 users

Excel VBATutorial                             Tutorial on Excel macros

 

Excel VBA Macros

Excel Macros Table of Contents

Excel Visual Basic Editor

Excel Macros Vocabulary

Excel Userforms

Excel Consulting

Excel Tutorial on Macros

Here is a sample of what you will find in lesson 7 of the downloadable Tutorial on Excel macros

Lesson 7 on Excel macros (VBA):

The Excel Macro Recorder (1997 to 2006)

Note: If you are using Excel 2007 to 2010 see lesson 7 here

IMPORTANT NOTE 1: There are no risks to your computer or to Excel in completing the exercises below. At any time if you feel uncomfortable just close Excel without saving the workbook and retry.

One of the tools that makes the programming environment in Excel unique is the Excel Macro Recorder. When you start the macro recorder anything you do in Excel is recorded as a new macro. That makes the macro recorder the best VBA teacher and also a great assistant who will write a lot of the words and sentences that you need without a single typo. It will also be there when you do not remember something that you do not use often. Even after many years of programming you will still use the macro recorder daily not to learn anymore but to write code (VBA words and sentences).

With the Excel macro recorder you can not develop a macro that will damage Excel or your computer so try anything and learn.

In this lesson on line you will record a macro and run it.

Recording Your First New Macro:

Exercise 1 (Record your first macro and use it)

Step 1: Print this page.

Step 2: Open Excel and a new workbook.

Step 3: Go to "Tools/Macro" and click "Record New Macro..."

Step 4: A small window appears titled "Record Macro". We will review its components in the downloadable tutorial. For now just click on "OK".  

Excel macros definition

The macro recorder is ON.

Step 5: In the sheet below (Sheet1) select cells B1 to B5, go to "Sheet2", select cell B6, come back to "Sheet1" and select cells D2 to D5.

Step 6: Go to "Tools/Macro" and click "Stop Recording"

Running your first recorded macro

Exercise 2 (Record your first macro and use it)

Step 1: Select cell "A1" of "Sheet1".

Step 2: Go to "Tools/Macro" and click "Macros..."

Step 3: In the window that appears Macro1 is selected.

Excel run macro

Again we will forget about the components of this window because we will study them in the downloadable tutorial. For now, just click "Run".

Step 4: See how fast the macro runs. You do not even see Excel go to Sheet2 (but it does). At the end of the execution cells D2 to D5 are selected.

What took you around 5 seconds to do manually (step 5 of the first exercise) took Excel a fraction of a second. Excel can work much faster than you can. Welcome to the marvelous world of VBA for Excel (Macros).

You can repeat steps 1 to 4 of this second exercise as often as you like.

Looking at your first recorded macro

To complete this third exercise you must have studied lessons 1 to 4. Go to the Visual Basic editor and you will see the following macro in the code window when you double click on Module 1 in the Project Window:

Sub Macro1()

' Macro1 Macro

    Range("B1:B5").Select
    Sheets("Sheet2").Select
    Range("B6").Select
    Sheets("Sheet1").Select
    Range("D2:D5").Select

End Sub

You knew how to select a cell, a range and a worksheet with the mouse, you now know how to tell Excel to do the same thing using VBA.

Never forget that the Excel macro recorder is your best teacher and will remain a great assistant for the rest of your VBA developer's life.


We hope you have enjoyed this introduction to lesson 7
for more on this topic and a complete course on Excel macros download the
Tutorial on Excel Macros


Next Lesson: Macros Help and Assistance

 

Excel Tutorial on Macros

Excel VBA Macros

Excel Macros Table of Contents

Excel Visual Basic Editor

Excel Macros Vocabulary

Excel Userforms

Excel Consulting