
Learn how to automate Excel tasks with Excel VBA, mastering Visual Basic for Applications to boost productivity, understand basic programming concepts, and manipulate data with fast VBA code.
Set up Excel for macros, save as a macro-enabled workbook, and enable the developer tab; then learn recording, editing, and running macros in the Visual Basic Editor.
Learn about variables and numeric types in Excel VBA, using the Visual Basic Editor, Option Explicit, integers, long, doubles, and basic arithmetic with the Immediate Window debugging.
Explore the string type in Excel VBA, declare a string variable, concatenate with ampersand, and manipulate text using UCase, LCase, Replace, Left, Right, Mid, Len, and InStr.
Declare boolean variables in Excel VBA, assign true or false, use not, and, or, and compare strings with greater than, less than, and equality operators.
Learn how the if statement uses a boolean condition to check password length and digits, prompting input with an input box and displaying feedback via a message box.
Explore VBA looping using do while, do until, and for loops to repeat code, control flow with step sizes, and exit statements, including a password check for digits 0–9.
Learn to manipulate worksheet cells with ranges and reference sheets by active, name, or index, and use the set keyword to assign worksheet and range objects.
Learn how to use subs and functions in Excel VBA to create reusable code. Pass arguments, return values, and loop through ranges with for each.
This lecture teaches beginners how to build a vba macro in Excel to format phone numbers from a single-column selection, extracting digits, assembling (xxx) xxx-xxxx formats, and handling extensions.
Overview
This is a one-hour course that is intended for Excel users who want to learn how to automate their tasks. Excel, as well as other Microsoft Office programs, come with a powerful scripting language known as VBA. With a little bit of programming knowledge, complex tasks can be fully automated and completed in seconds. This course assumes no programming experience; only a reasonable level of familiarity with Excel.
Prerequisites
Microsoft Excel : This courses uses Excel 2007 for the demonstrations, and comes with .xlsm files for the code examples. These demos and files will be compatible with later versions of Excel as well. If you are using Excel 2003, you will not be able to open the .xlsm files, but you will be able to follow along with the demos.
What you will learn
The course begins with an introduction to macros. You will learn how to record a sequence of actions, how to run the recorded macro, and how to inspect the VBA code that gets generated from this process.
You will then learn how to use numbers in VBA. There are different types of numbers which are used in different situation, so you'll be a given an overview of the differences between them. You will be shown how to do simple arithmetic operations inside your VBA code.
You will then be introduced to strings. Strings are used in programming to represents words and characters. For example, "hello world" could be stored in your VBA code as a string. You could then perform various operations on your string, such as converting it to upper-case, replacing a word, counting the number of characters, and many others.
Then you will look at booleans, if-statements and loops. These concepts will allow you to create complex behaviors that would not have been possible by simply recording a macro. You will able to write code that implements logical rules and makes decisions.
Ranges and Worksheets will be introduced next. These objects are what will allow you to read and manipulate your Excel data from your VBA code. We will then move on to subs and functions. These will allow you to organize your code into small, cohesive pieces, making it easier to reason about complex tasks.
Finally, we will end the course with a simple, practical exercise. We will take a list of phone numbers that are in inconsistent formats, and write some code that will convert them into a standard format at the press of a button.