
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.
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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.
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;
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;
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;
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;
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;
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;
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 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;
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;
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;
This lesson looks at using a conditional loop to check and update an inventory list.
This lesson covers;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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;
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 |
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;
Using VBA you can create loops to repeat a set of actions for every workbook within a directory, or folder.
This lesson covers;
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;
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;
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;
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;
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;
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.