Main Course Lessons and Exercises

The estimated total time to take the course is between 12 and 16 hours. The time will vary depending on the person taking the course.

Chapter 1. The Visual Basic Editor

Lessons

Opening the VB Editor
Parts of the VB Editor
Project Explorer Window
Inserting a Code Module
Properties Window
Referring to Worksheets with Code
Toolbars in the VB Editor
Saving Your Work
Stepping Through Code in Break Mode
Record a Macro and Modify the Code

Exercises

Open the VB Editor
Insert a code module
Activate worksheets with code
Adding VB Editor toolbars
Stepping through code
Record a macro and modify the code

Chapter 2. Code Structures, How to Enter Code

Lessons

Code Blocks
Sub...End Sub Block
Function...End Function Block
Statements: Capturing and Assigning Values
Making Decisions: If and Select Case
Loops: For, For Each, and Do Loops
'For' Block Variations
Do Loop
With...End With

Exercises

Indenting code blocks
Write a sub that calls a function
Write a Select Case block
Write 'For' blocks
List all Excel workbooks in folder
Add and name a worksheet

Chapter 3. Variables and Options

Lessons

Variable Types and Declarations
Variant Data Type
Declaring Variables
Option Explicit: Requiring Variable Declaration
Variable Scope
Deftypes
Two Useful Options
Colons Separate Code Lines

Exercises and Demos

Declaring a variable with a Dim statement
Invoking Option Explicit in a code module
Requiring variable declaration all the time
Using a Public variable
Using Deftypes
Compare Text Option

Chapter 4. Coding Common Excel Objects

Lessons

Excel Object Model
Workbook
Worksheet
Range
Cell
Collection Objects
Looping Through Workbooks
Collection Looping Using the Count Property

Exercises

View the Excel Object Model
Referring to workbooks in code
Use the ActiveSheet property and add a worksheet with code
Building a range dynamically and clearing the range
Using Cells object in a For loop
Looping through the workbooks collection
Looping through a collection using the Count property

Chapter 5. Buttons, DropDowns, and Other Controls

Lessons

Introduction to Controls
Properties and Methods
Common Properties and Methods
User Input
Message Box
Input Box
Controls and the Custom Excel Front-end
Forms Toolbar
Dialog Sheet
UserForm
Make and Use a Custom Align Toolbar
Create a Sheet Navigation Button
Fill a List Box and Use the List
Use Format Control to Fill a DropDown Box
Create and Code Option Buttons
Check Boxes and Text Boxes
Advice for Custom Applications

Exercises

Coding with MessageBoxes
Coding with InputBoxes
Adding the Forms and Drawing toolbars
Insert a Dialog Sheet
Insert a UserForm
Building a custom toolbar for aligning controls
Aligning and spacing three buttons on a worksheet
Create a sheet navigation button
Fill a List Box using VBA
Assign a macro to a List Box and capture the List Box selections
Format a DropDown Box: prepare the workbook
Format a DropDown Box: link DropDown Box to named ranges
Using Option Buttons on a worksheet

Chapter 6. Dialogs, UserForms, Control Toolbox

Lessons

Coding with MessageBoxes
Coding with InputBoxes
Adding the Forms and Drawing toolbars
Insert a Dialog Sheet
Insert a UserForm
Building a custom toolbar for aligning controls
Aligning and spacing three buttons on a worksheet
Create a sheet navigation button
Fill a List Box using VBA
Assign a macro to a List Box and capture the List Box selections
Format a DropDown Box: prepare the workbook
Format a DropDown Box: link DropDown Box to named ranges
Using Option Buttons on a worksheet

Exercises

Create a dialog sheet with controls
Setting up a button to show a dialog
Testing the dialog sheet code
Creating a UserForm for formatting a worksheet cell
Create and configure a list box, combo box and buttons on a UserForm
Write VBA for a combo box, multi-select list box, and command buttons on a UserForm
Create, configure, and code a Control Toolbox button that shows a UserForm

Chapter 7. Debugging and Error Handling

Lessons

Errors Happen
Compile Error: Ambiguous Name Detected
Compile Error: Block If without End If
Run-time Errors: Spelling 101
Debug Run-time Errors by Checking Variable Values
Error Handling
Breakpoints
Collection Looping Using the Count Property

Exercises

Ambiguous name compile error
Block If without End If compile error
Avoiding spelling mistakes
Stepping through code watching variables
On Error Goto: Handling Input Box entry error
Handling a SpecialCells error
Breakpoints

Chapter 8. Applied VBA

Lessons

Code Snippets, Applets, and Tips
Function for Finding Last Row
Exporting and Importing Code Modules
Dialog Wizard With UserForms
Protecting Your VBA Project
Looping Through a Folder for Workbooks
Writing To and Reading From Text Files

Exercises and Demos

Use the gLastRow function
Naming, exporting, and importing code modules
Tour the deck wizard applet
Demonstration of protecting VBA code
Looping through a folder using Dir
Writing to and reading from a text file