Excel VBA - The Complete Excel VBA Course for Beginners
4.5 (1,207 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
6,973 students enrolled

Excel VBA - The Complete Excel VBA Course for Beginners

Learn Excel VBA and take your spreadsheets to the next level.
4.5 (1,207 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
6,973 students enrolled
Created by Alan Murray
Last updated 3/2019
English [Auto]
Current price: $65.99 Original price: $94.99 Discount: 31% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 12.5 hours on-demand video
  • 8 articles
  • 53 downloadable resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Write powerful Excel VBA code to automate processes
  • Identify real world situations where you can apply your new VBA skills
  • Understand, test and debug VBA errors
  • Lifetime access to the lessons, practice files, exercises, and 1-on-1 instructor support
  • Fun and effective lessons including 'real world' Excel VBA projects to complete
  • Projects and challenges to practice your skills
  • An intermediate to advanced knowledge of Excel
  • The course is taught in Excel 2010, but the lessons will work in any version unless stated
  • No prior programming skills are necessary. The course starts with the basics

Hear What Some of Our Students are Saying.....

"Really, really good course on VBA! *****"

"Great content, great examples, would definitely take another course from this instructor again!"

"Excellent course for getting started with VBA. The instructor makes every concept clear, and guides you through with many examples.

"Great course for a beginner or as a refresher. I know I will be coming back to some of these lectures as needed for some of his code tidbits because as he says, "you can't remember everything", and I love knowing where I can find what I am looking for.

Want to take your Excel skills to the next level and learn Excel VBA? Well, you have come to the right place.

This course covers everything you need to become proficient in Excel VBA. In just a few hours you can be writing your own macros to perform complex tasks and automate reports.

Areas covered include; 

  • Learning the basics of the VBA language.

  • Using loops to perform repetitive tasks.

  • Interacting with users via userforms and message boxes.

  • Working with built-in VBA Functions.

  • Accessing directories and files.

  • Automating report generation and saving as PDF.

  • Creating your own Excel functions and Add-Ins.

You will receive; 

  • Support from the Instructor.

  • Lifetime access to lectures and content.

  • Real-world Excel VBA projects to complete.

  • Fun and no-nonsense lessons.

  Ok, no more time for waffle. Grab a coffee and let's get cracking. 

Who this course is for:
  • You want to learn VBA to take your skills to the next level
  • You want to automate reports and save time on repetitive and boring tasks
  • This course is probably not for those with VBA experience who are looking for advanced VBA.
Course content
Expand all 75 lectures 12:19:09
+ Introduction
2 lectures 03:17

Download these files so that you can follow along and practice the code demonstrated in the videos of the course.

This folder includes both the incomplete and finished versions of the files used on the course.

Download These Files First
+ Recording your First Macro
8 lectures 01:05:17

Before we begin writing our own code, we need to look at recording macros. However good you get at writing VBA code, there will always be a place for recording. It saves you time, gives you ideas and helps you understand tasks you are not familiar with.

By recording a macro, we ask Excel to watch us as we perform actions on a spreadsheet. We stop the recording when we have finished, and from now on these actions can be performed with the click of one button.

This tutorial covers;

  • Recording a macro to protect the cells on a worksheet that contain a formula
  • What you can, and cannot, do when naming macros
  • Where you should save your macro
Preview 14:29

After recording a macro you will need some way of initialising it. This will commonly come in the form of a button, and the most popular place to position that button is the Quick Access Toolbar.

This toolbar is always visible at the top of the screen making it the easiest way to trigger your macro.

This tutorial covers;

  • Assigning a macro to a toolbar button
  • Making the button available to all spreadsheets, or to only one specific file
  • Customising the image and text of the button
Preview 06:42

You can customise the Ribbon in Excel 2010 and later versions. The Ribbon provides a much larger space to position your macro buttons and also any other Excel commands you wish to add.

By taking the time to customise the Ribbon and toolbar in Excel, you can make your tasks faster and easier over the long haul.

This tutorial covers;

  • Creating a new tab on the Ribbon
  • Creating additional groups on the Ribbon tabs
  • Renaming the tabs and groups
  • Assigning a macro button to a group on the Ribbon
  • Customising the image and text of a button
Preview 07:42
Editing your Macro Code 1

When selecting cells whilst recording a macro, the macro records these as absolute references. You can toggle between relative and absolute references during a recording to get the correct behaviour from your macro.

This tutorial covers;

  • Recording a macro that consolidates data onto one worksheet
  • Using relative references in a macro
  • Viewing the VBA code generated by the recording and editing parts
Preview 06:38

An Excel file that contains a macro should be saved as a macro enabled file. Macros will not be available in files saved as a workbook.

Depending on the user’s settings, a user will be prompted to enable macros on the spreadsheet when opening the file.

This tutorial covers;

  • Excel warning you about saving as a macro free workbook
  • Saving as a macro enabled workbook
  • Modifying macro security settings
  • The message bar prompting a user to enable macros on a workbook
Preview 05:32

VBA or Visual Basic Applications is the programming language behind all office applications. By writing or editing this code you can take your macros to another level.

You can create some awesome macros by recording, but the real power lies in writing the VBA. Using VBA you can create complex macros that enhance the capabilities of Excel.

This tutorial covers;

  • Understanding some of the VBA code generated by our protecting formulas macro
  • Edit the code to tidy it up and correct mistakes
  • Add an IF statement to exit the macro if the sheet is already protected
  • Add the msgbox VBA function to display a message to the user upon exiting
Preview 06:08

Buttons can also be added to the worksheet to initiate your macros. This can be popular with macros that submit forms and dashboard reports.

This tutorial covers;

  • Showing the Developer tab on the Ribbon
  • Inserting a command button and assigning a macro to it
  • Inserting a shape and assigning a macro it
  • Formatting your command buttons and shapes
Preview 05:50
+ Getting Started with VBA
8 lectures 01:30:24

The Visual Basic Editor is the environment that you will be performing your VBA work. It can be accessed via the Developer tab or by pressing Alt + F11.

This lesson covers;

  • Opening the Visual Basic Editor
  • Exploring the VBE window
  • Inserting a module for your code
Preview 07:38

In this lesson we create a macro from scratch and begin to write our first code. Its a simple little bit of code to start with so we begin to understand the VBA object model and get familiar with VBA terminology and grammar.

This lesson covers;

  • Inserting a module and renaming it
  • Creating a new sub procedure
  • Laying out code
  • Writing comments
  • VBA syntax and terminology
  • Running a sub procedure
  • Referencing cells and changing values
Writing your First Macro

You will always have a need to record a macro. It will generate code for you quicker than you can type, and help you learn the VBA for specific Excel commands you have not written before.

However recorded code is not as clean as written VBA and can often need some tidying up afterwards.

This lesson covers;

  • Two typical examples of the macro recorder generating redundant code.
  • Editing the code so that it is faster and easier to read.
Cleaning Recorded Code

When you write functions and use object methods in VBA, they may prompt you for information known as arguments. This is the same behaviour that you get when you write functions in Excel.

There are a few different ways that you can write arguments in VBA. You can write them shorthand or be more descriptive.

This lesson covers;

  • Using the arguments for the Copy method.

  • Writing arguments in both shorthand and the more descriptive format.

  • Understanding whether an argument is required.

Preview 08:39

Your VBA code is sure to have to refer to different cells, sheets and books. There are many different techniques for doing this. What you use depends on your location when you write the reference, and why you are doing it.

This lesson covers;

  • Techniques for referring to different workbooks.
  • Techniques for referring to different sheets.
  • Techniques for referring to cells such as the ActiveCell, Range, Cells, defined names and Selection.
  • Inputting values to cells.
  • Copying and pasting values.
  • Using the Offset object.
  • Stepping through code to understand and troubleshoot it.
Referring to Cells, sheets and Workbooks

There are three different types of error, logical, syntax and run-time errors. Until these errors are resolved you will not be able to run your procedures, or they will not run effectively.

This lesson covers;

  • Debugging syntax errors.
  • Debugging run-time errors.
  • Working in Break Mode.
Errors in VBA

This quiz contains questions from the Introduction to VBA section.

Introduction to VBA Quiz
7 questions
Recording and Editing Macros Challenge
Recording and Editing Macros Challenge Answer
+ Working with Variables
4 lectures 46:38

Variables are used to store data during a macro. They can store data captured from a function, userform or message box.

They are faster, more meaningful and more dynamic than storing data in a worksheet They are a fundamental skill of VBA programming that will be used throughout the rest of this course.

This lesson covers;

  • Using variables to store data during a procedure.
  • The importance of declaring variables.
  • How to declare variables and understanding different variable data types.
  • Tracking variables using the Locals Window.
Using Variables

Declaring your variables is not required in VBA. However it is highly recommended to create faster, more readable code that is also easier to track and debug.

This lesson covers;

  • Use Option Explicit to force variable declaration.
  • Set the Editor to require variable declaration in all code modules.
  • Common VBA errors relating to using variables.
The Role of Option Explicit

The scope of a variable is its Accessibility to other procedures in the project.There are three levels of Scope: Public Module, Private Module and Procedure.

This lesson covers;

  • Declare and use a variable accessible to all procedures within a module.
  • Create a variable accessible to procedures across all modules of a project.
Variable Scope

Using an object variable allows you to store a reference to an Excel object. This object can be a range of cells, sheet, workbook or any other Excel object.

Using such a variable makes referencing that object during your code easier, faster and more readable.

This lesson covers;

  • Declaring object variables.
  • Using the Set keyword.
  • Using Worksheet and Range object variables.
Using Object Variables

This quiz tests your knowledge on topics covered in the Using Variables section.

Using Variables Quiz
5 questions
+ Making Decisions
2 lectures 16:07

The If statement provides decision making for your code. It can be used for a single or multiple tests. The structure for an If statement is shown below.

This lesson covers;

  • The structure of the If.. Then.. Else statement
  • Writing single and multiple test If statements
  • Using AND and OR logic
If..Then..Else Statements

The Select Case statement compares a single test expression against multiple possible values. Each case test consists of a test and an outcome to that test. The outcome statements may be multiple lines.

Select Case is considered more concise and readable than the equivalent If structure. The structure of Select Case is shown below.

This lesson covers;

  • The structure of the Select Case statement
  • Using Select Case for multiple tests on a value
Select Case Statements
+ Looping
12 lectures 01:49:50

Conditional loops are used to repeat a set of instructions while a certain condition is satisfied, or until a certain condition is satisfied.

This lesson covers;

  • Writing Do While and Do Until loop structures.
  • Checking a condition before the loop, or after executing the command once.
Conditional Loops

The Cells object provides a fast and effective way to reference cells when using loops. It is a better alternative to using Activecell and its Offset property when you are looping through a very large list.

This lesson covers;

  • Understanding the benefits of the Cells object in loops.
  • Use the Cells object to reference cells in a Do Until loop.
Using the Cells Object with a Loop

This lesson looks at using a conditional loop to check and update an inventory list.

This lesson covers;

  • Using a Boolean variable for the loops condition.
  • The Do Until loop structure to loop through a list until an entry is found, or we hit the bottom of the list.
  • Adding new stock to the list and enter todays date for the transaction.
  • Using the Cells object to reference the cells in the list.
Conditional Loops - Updating an Inventory List

Counter loops iterate a loop for a specific number of repetitions. We can enter the specific number of repetitions for the loop, or use a variable or collection.

This lesson covers;

  • Writing the For Next loop structure.
  • Using a counter loop to remove the blank rows from a worksheet.
  • Using the CountA function to count non-bank cells.
Counter Loops - Delete Blank Rows on a Worksheet

Counter loops can be used to iterate through every object within a collection. For example, to loop through all the worksheets in a file, or through every open workbook.

This lesson covers;

  • Using the For Next loop structure to loop through every worksheet in a file.
  • Protect the worksheets of a workbook.
Counter Loops - Protect All the Worksheets in a Workbook

Collection loops repeat a set of instructions on every object within a collection. Object variables make it easier to reference the objects during the loop.

This lesson covers;

  • Writing the For Each Next loop structure.
  • Using a collection loop to perform an action on every cell within a range selected by the user.
  • Convert text to uppercase using the Ucase function.
Collection Loops - Convert Selected Text to Uppercase

Loops can be inserted into other loops creating interior and exterior loops, or nested loops. Any loop can be inserted inside another is used for many reasons. For example, to loop through all the worksheets (interior loop) for multiple books (exterior loop), or to loop through all cells in a range (interior loop) on all worksheets of a book (exterior loop).

This lesson covers;

  • Using multiple Do loops.
  • Getting our inventory list spreadsheet to update for multiple stock items.
  • Making edits to your code to work with nested loops.
Nesting Loops - Updating an Inventory List 2

A big aspect of an efficient procedure is the speed that it executes. The more calculations you ask it to perform, information it stores and loops it goes through will all contribute to the weight of your procedure.

There are a few settings that can be switched off to improve the speed that a procedure executes, and to stop interference whilst it runs.

This lesson covers;

  • Changing application settings to dramatically improve the speed a macro executes.
  • Changing settings to prevent interference from the application whilst a procedure executes.
Make your Procedures Faster and Stop Interference
Looping Challenge
Looping Challenge Answer
Looping Challenge 2
Looping Challenge 2 Answer
+ Error Handling and Debugging
6 lectures 01:04:39

One thing you can almost guarantee is that your code will contain bugs at some point. A bug simply means that your code is not functioning properly. They are typically generated by typing mistakes, or errors in the code’s logic.

This course has already covered some techniques for solving bugs in our code. This lesson explores a few other debugging tools that you might find useful.

This lesson covers;

  • Using Breakpoints to stop code running at specific points.
  • Using the Immediate Window to test code and check the values of variables and cells.
  • Using the Watch Window to track specific variables and get code to break dependent upon expressions.
  • Solving two minor bugs in the code of our inventory list spreadsheet.
Debugging Code

There are many reasons why Runtime Errors occur in a procedure. The ability to handle these errors before they happen is an essential part of VBA programming.

The On Error Resume Next statement is used to shut errors down so that your code continues to run, and is not interfered with.

This lesson covers;

  • How to use the On Error Resume Next statement in a procedure.
  • An example of how this statement can be used to prevent errors occurring during a procedure.
  • An understanding of the limitations of this statement and when not to use it.
On Error Resume Next

Error handlers can be created to effectively handle runtime errors in a procedure. An error handler is a section of code created to run in the case of an error occurring.

This lesson covers;

  • Using the On Error GoTo statement.
  • Creating an error handler.
  • Ensuring the error handler only executes when necessary.
  • Disabling an error handler.
Creating Error Handlers

You may need to set up multiple error handlers in your code. When using multiple error handlers you need to be sure that the correct handlers are triggered at the correct times.

This lesson covers;

  • Creating multiple error handlers.
  • Using the Resume statement.
Using Multiple Error Handlers

There are different types of runtime error that can occur in your code. The Err object can be used to identify which error occurred, and then run the required code to handle it.

This lesson covers;

  • Using the Number property of the Err object.
  • Testing the Err object to see what error occurred and take the necessary action.
The Err Object

For errors that you anticipate being caused by user error, there may be better ways to handle them than creating error handlers and using the On Error statement.

Other techniques can include using some of Excel’s existing functionality, or writing different VBA that tests for these specific issues.

This lesson covers;

  • Using Excel features such as Workbook Protection and Data Validation and prevent errors occurring.
  • The IsNumeric function.
Other Ways of Handling Anticipated Errors
+ User Interaction
3 lectures 40:57

Message boxes are one of the most popular ways of interacting with a user. They allow you to ask a question and provide buttons to capture the user response.

This lesson covers;

  • Wrapping message box text onto more than one line.
  • Using a message box in statement and function form.
  • Displaying different buttons on a message box.
  • Capturing a user’s response for decision making in a procedure.
Message Boxes - Updating an Inventory List 3

Input boxes are used to capture typed entries from a user. For example, asking a user which worksheet to open, or item to search for.

Input boxes can be used to capture numeric entries, dates, Boolean values and even cell references. They are however typically used to capture strings.

This lesson covers;

  • The syntax of the input box.
  • Using an input box to capture text and numeric entries.
  • Validating data entered by the user.
  • Using an input box in its function form and as a method of the application object.

Below is a list of type index numbers when using an input box in method form.








True or False


Cell reference


Error value


An array of values

Input Boxes

The built-in dialog boxes of Excel such as the Save As, Open File and Select Folder dialog boxes can be initiated using VBA code. These dialog boxes provide a familiar interface to a user for performing common tasks such as opening a file.

This lesson covers;

  • Initiate the Save As dialog box for a user to save a file.
  • Modifying the properties of a dialog box.
  • Validating the user’s interaction with the dialog box.
  • Capturing the information entered to save the workbook.
Dialog Boxes - Using the Save As Dialog Box
+ Working with Files and Folders
3 lectures 47:56

Using VBA you can create loops to repeat a set of actions for every workbook within a directory, or folder.

This lesson covers;

  • Storing a procedure in the Personal Macro Workbook.
  • Using a built-in dialog box to make it easy for a user to select a folder.
  • Using the Dir function for retrieving file names.
  • Looping through all the files within a specified folder.
Loop Through all Files in a Folder

When accessing files in a directory you may want to be more specific about what files you want to use. There is also various information you can access about the files.

This lesson covers;

  • Using the Dir and Right functions to retrieve only files of a specific file type.
  • Listing all the text files from a folder on a worksheet.
  • Printing information about a file such as size and date last modified to a worksheet.
Loop Through Specific Files of Type - List File Names on a Worksheet

When opening and saving files you may need to test to see if a directory currently exists, and if not create it during the procedure.

Saving a spreadsheet as a PDF is useful when sending data to clients, or providing it for customers. This procedure completely automates the report creation process.

This lesson covers;

  • Testing to see if a directory already exists.
  • Creating a directory on the fly in a procedure.
  • Saving each worksheet as a separate PDF to a folder.
Create Directories and Export as PDF
+ Working with Arrays
3 lectures 43:24

An array is a variable that can store more than one element of data. You can think of an array as a table of related data. Arrays can store data of any type.

Using data stored in an array is faster and more efficient than using data stored in worksheet cells.

This lesson covers;

  • Declaring a one-dimensional fixed array.
  • Populating an array with data from the cells on a worksheet.
  • Using the data stored in the array in a procedure.
  • Erasing an array.
Introduction to Arrays – One-Dimensional Fixed Arrays

Arrays can have multiple dimensions. An array can have as many as 60 dimensions. This makes them able to store complex lists of related data.

This lesson covers;

  • Declaring a two-dimensional fixed array.
  • Populating and using the data from the array.
Two-Dimensional Arrays

You will not always know the size of an array at the time you declare it. Fortunately you can re-dimension, or resize, an array during a procedure. You can resize an array as many times as necessary. This is known as a dynamic array.

This lessons covers;

  • Declaring a dynamic array.
  • Re-dimensioning an array.
  • Populating a dynamic array.
  • The LBound and UBound functions.
  • Using Preserve when re-dimensioning an array.
Dynamic Arrays