Excel VBA Course - Automate Repetitive or Complex Tasks
4.4 (318 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
3,493 students enrolled
Wishlisted Wishlist

Please confirm that you want to add Excel VBA Course - Automate Repetitive or Complex Tasks to your Wishlist.

Add to Wishlist

Excel VBA Course - Automate Repetitive or Complex Tasks

Learn Excel VBA and take your spreadsheets to the next level.
4.4 (318 ratings)
Instead of using a simple lifetime average, Udemy calculates a course's star rating by considering a number of different factors such as the number of ratings, the age of ratings, and the likelihood of fraudulent ratings.
3,493 students enrolled
Created by Alan Murray
Last updated 3/2017
English
Current price: $49 Original price: $95 Discount: 48% off
30-Day Money-Back Guarantee
Includes:
  • 12 hours on-demand video
  • 9 Articles
  • 14 Supplemental Resources
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
What Will I Learn?
  • Write powerful Excel VBA code to automate processes
  • Impress your boss and colleagues by adding code to speed up repetitive tasks
  • Identify real world situations where you can apply your new VBA skills
  • Understand, test and debug VBA errors
View Curriculum
Requirements
  • Microsoft Excel
  • Intermediate/Advanced knowledge of Excel
Description

- Join over 2,500 Students in Learning Excel VBA

- This Course has Received More Than 80 Five Star Reviews

- Last Updated 21st February 2017


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 the 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 is the target audience?
  • Excel users who want to learn VBA to take their skills to another level
  • No prior programming skills are necessary. The course starts with the basics
  • This course is probably not for those with VBA experience who are looking for advanced VBA.
Curriculum For This Course
73 Lectures
11:54:57
+
Introduction
2 Lectures 00:51
Introduction
00:44

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
00:06
+
Recording Macros
7 Lectures 01:00:23

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 11:33

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:34

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:34

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:18

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 06:29

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 07:46

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 15:09
+
Getting Started with VBA
8 Lectures 01:38:10

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 08:39

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
23:11

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
11:08

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 Protect method of the Activeworkbook object.
  • Writing arguments in both shorthand and the more descriptive format.
  • Understanding whether an argument is required.
Preview 08:45

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
29:52

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
08:23

This quiz contains questions from the Introduction to VBA section.

Introduction to VBA Quiz
7 questions

Recording and Editing Macros Challenge
00:42

Recording and Editing Macros Challenge Answer
07:30
+
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
17:24

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
10:27

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
09:08

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
09:39

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
10:04

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
06:03
+
Looping
12 Lectures 01:44:28

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
08:25

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
06:36

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
24:53

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
14:49

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
05:50

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
08:05

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
16:16

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
09:53

Looping Challenge
00:29

Looping Challenge Answer
05:58

Looping Challenge 2
00:20

Looping Challenge 2 Answer
02:54
+
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
18:51

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
05:39

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
09:18

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
15:33

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
07:03

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
08:15
+
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
11:14

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.

0

Formula

1

Number

2

Text

4

True or False

8

Cell reference

16

Error value

64

An array of values

Input Boxes
15:25

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
14:18
+
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
21:04

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
12:02

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
14:50
+
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
17:11

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
11:45

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
14:28
5 More Sections
About the Instructor
Alan Murray
4.5 Average rating
422 Reviews
4,095 Students
5 Courses
Founder of Computergaga

Alan Murray is a Microsoft Office trainer and consultant. He has been training and consulting for the past 15 years for businesses around the world.

He is the founder of Computergaga and regularly writes on the Computergaga blog to share tips, tutorials and templates.

Alan uses a fun and relaxed style of training that gets to the point, and uses real world practical examples uncovered from his experience of training and developing software for businesses.

Files are provided to follow along and exercises used to recap on topics covered. Alan is always eager to help and will be there for you when needed. He will do his best to answer any question or query related to his courses within 48 hours.