Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Excel Macros
Rating: 4.4 out of 5(29 ratings)
1,129 students

Excel Macros

Everything you need to know to start working with Macros in Excel
Created byBranka Bradule
Last updated 2/2021
English

What you'll learn

  • Record, edit and debug a macro in Microsoft Excel

Course content

7 sections37 lectures3h 3m total length
  • Introduction3:13

    The course covers everything you need to know to start working with Macros in Excel.

    We will cover different features of the Visual Basic Editor interface; show you how to record, edit, debug, and manage macros; and learn about the syntax that VBA uses to create macros.

    By the end of this course, you should be comfortable with creating, recording, editing, and debugging a macro.

  • Theoretical background8:39

    In this lecture, we will cover some theoretical aspects, because it is very important for you to understand basic terminology and methodology related to macros, VBA, and object-oriented programming.

    If you wish you can skip the theory and head straight to Lecture 5 in which we will record our very first macro, however, I do recommend investing 10-15 minutes needed to listen to this lecture, as it will help you to understand further concepts much better.

  • Macro Options6:22

    In this Lecture, we will get to understand Macro Options, which will display a list of all macros you can work with.

    To view existing macros that may be available to you in Excel or to change how macros are handled, open the Macro dialog box by clicking ViewMacros:

    In the Macro dialog box, the “Macro name” box will list existing macros in any of the currently open workbooks. Select a macro to view information about it within the Description section.

    Other commands in this dialog box.

    • The “Macros in” drop-down menu lets you choose to list any macros that are stored in specific areas, such as only the currently displayed workbook.

    • The Run button will execute a selected macro, while the Step Into button allows you to execute the next line of code in the Visual Basic Editor.

    • The Edit button allows you to make changes to a selected macro.

    • The Create button will display the Visual Basic Editor, where you can create a new macro from scratch.

    • Clicking Delete will delete the selected macro.

    • Clicking the Options button allows you to specify a shortcut key to run a selected macro. You can also specify a description for the macro.

    If you wish to record a new macro you can use Macro Recorder, which will record all actions you make within Excel and translate them into VBA code.

    To record a macro with Macro Recorder:

    • Navigate to the View or Developer tab

    • Click on the Record Macro button

    • In a new dialog box add the Macro Name, Shortcut key (Optional), select Storage location*, and add a description (Optional)

    • Start the recorder

    • Complete all of the actions to apply those settings

    • Stop the recorder.

    Once the process is complete, the Macro Recorder will translate the actions you completed into VBA code and save it as a macro that you can use again and again.

    * If you will decide to store the macro in the Personal Macro Workbooks, you will be able to use such macros with any workbook that you open on your computer. This storage area is unique to your computer and your user account, so you are able to store the macros that you use most frequently here and always have access to them. This system saves you the trouble of having to copy frequently used macros to every workbook that you use. After such macro is recorded, you can access this storage area using Windows Explorer by browsing to the “C:\Users\[User Name]\AppData\Roaming\ Microsoft\Excel\XLSTART” folder. (This location is valid for Windows Vista, Windows 7, Windows 8, Windows 8.1, and Windows 10.)

  • Add Developer tab to the Ribbon1:04

    Although you can record macros by clicking the Record Macro icon in the Macros group on the View tab, the Developer tab contains commands that allow you to work with macros and manage them with more control.

    This tab is hidden by default and needs to be added to the ribbon before you can use it. You can do so by:

    • Navigate to the File tab

    • Select Options in the bottom left corner

    • On the right side, from the Categories menu choose the "Customize Ribbon" category

    • Check the Developer checkbox in the list on the right-hand side

    • Click OK to apply the new settings

    • The Developer tab will now appear on the ribbon

  • Let’s check what we learned
  • Create a macro using macro recorder6:58

    In this lecture, we will see how macros are translated into VBA code. To open the VBA editor you can press Alt + F11 on the keyboard. When the VBA editor opens, navigate to the modules folder, select the correct module and check macro code on the right.

    Here you will see that all the actions that we performed while recording the macro, were translated into the VBA code.

    For the example presented in this lecture:

    1. We can see the macro's name, its description, and assigned shortcut key right here.

    2. Below we can see actions that were translated into the code. We can see that we have selected row number two and after that, we have inserted a new row.

    3. Further, we can see that we have also selected row number 4, but no other actions were performed for this row.

    You will see in the lecture, that when we were recording a macro example, right after inserting the first blank row, we came to row number 4, selected it but then we didn't perform any other actions. And this action of row number 4 selection was also recorded and stored in the VBA.

    We will also show how we can delete unneeded lines of code and how this will be reflected in the macro behavior.

  • More macro examples17:05

    In this lecture, we will see two more macro recording examples:

    1. First, we will record a macro, by which we will delimit the data to the columns, add an additional column, and perform calculation - all together will be stored in a macro.

    2. And then we record another one, by which we will format data as a table and change the date format.


  • Assignment 1: Instructions1:46

    In this activity, you will need to change workbook protection settings for dozens of workbooks that you control. To speed up this process, you will create a macro using the Macro Recorder.

    This macro will apply workbook protection to any workbook. To achieve that you will need to:

    • Start the macro recorder.

    • Name the macro.

    • Store the macro in the personal macro workbook.

    • Add the description.

    • And with active recording, you will need to navigate to the Review tab and toggle workbook protection on

    • When done, you will stop the recorder and test if your macro works fine.

  • Assignment 1: Solution4:56

    In this lecture, you will find the video showing the solution on how to complete Assignment 1.

Requirements

  • Have solid fundamental Microsoft Excel knowleadge

Description

This course is designed in a way to first explain some basic theory about macros and then to explain and show the most important aspects of Macros in Excel. We will not go into the depths, we will cover only the basic aspects which are needed to start recording, understanding, and editing macros. Right after the explanation, we will work on exciting examples to help you to consolidate newly gained knowledge on practical examples.

Topics that will be covered:

  • Theoretical background about Macros, OOP, and VBA editor

  • Creating Macros using Macro Recorder

  • Creating user forms

  • Binding a Macro to an object

  • Debugging

  • Quick Access Toolbar and Ribbon customization

In the beginning lectures of the course, we will cover first some theoretical aspects, because it is very important for you to understand basic terminology and methodology related to macros, VBA, and object-oriented programming. After understanding some basic macro theory, we will then start with macro creation using a macro recorder.

Once when we will have our first macro in place, we will understand the importance of the VBA editor, which is the only way to modify the macro we already recorded. Here I am going to show you how VBA comprised and the basic syntax for writing the VBA code.

Once when we get a bit more proficient in writing VBA code directly in VBA editor, we are going to write a simple program to do different things for us, such as clearing the content of specified ranges, printing active Excel sheet to pdf format, or generating numbers for invoices that we manage in Excel. I believe that this part will be the most interesting one and that we are going to have so much fun in this part of the course!

In each module, you will also receive Excel exercises to follow along with course examples and at the end of each module, you will be given an activity to complete.

At the end of the course, we will summarize what has been covered, work on additional exercises and provide a few review questions for you to answer.

Additionally, at the end of the course, you will get access to Lesson Labs to work independently on different examples. The purpose of lesson labs is for you to consolidate gained knowledge and to try to think outside the familiar area. Some examples in the lesson labs were covered during this course lectures, others were not. Even if solutions for all lesson labs are presented in the file which contains completed lesson labs, I encourage you to try to finish them on your own – even if it contains the additional research.

I look forward to seeing you inside the course.

Who this course is for:

  • This course is for Microsoft Excel users, who want to automate their repetitive tasks in Excel.