Skip to content
Tutorials Center
My learning

Topics

VBA Tutorial

Learn VBA step by step: 37 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is VBA? Learn what VBA is, which Office apps run it, what it is good for, and when to choose it over formulas, Power Query, Office Scripts or Python.
  2. 2 The VBA Editor and Macro Security Turn on the Developer tab, open the Visual Basic Editor, learn its windows, and understand macro security, trusted locations and safe file types.
  3. 3 Your First Macro: Sub, MsgBox and Running Code Write and run your first VBA macro: create a module, declare a Sub, use MsgBox and Debug.Print, run with F5, attach a button and fix simple errors.
  4. 4 Recording Macros and Reading the Code Use the macro recorder to capture actions as VBA code, understand what it generates, clean it up, and learn absolute versus relative recording.

Language Basics

  1. 5 Variables and Data Types in VBA Declare variables with Dim, choose between Integer, Long, Double, String, Boolean, Date and Variant, and learn naming rules, defaults and type conversion.
  2. 6 Option Explicit, Constants and Variable Scope Use Option Explicit to catch typos, define constants and enums, and understand procedure, module and public scope plus Static variables in VBA.
  3. 7 Operators and Expressions in VBA Learn VBA arithmetic, comparison, concatenation and logical operators, operator precedence, Mod and integer division, Like, Is and bitwise And/Or/Not.
  4. 8 Working with Text: VBA String Functions Master VBA text handling: Len, Left, Right, Mid, InStr, Replace, Split, Join, Trim, UCase, StrComp, Format and string building with practical examples.
  5. 9 Math and Date Functions in VBA Use VBA math functions (Abs, Int, Round, Sqr, Rnd) and date functions (Now, DateAdd, DateDiff, DatePart, Weekday, DateSerial) with practical examples.
  6. 10 Arrays in VBA: Fixed, Dynamic and Multi-Dimensional Learn VBA arrays: fixed and dynamic arrays, ReDim Preserve, Array(), two-dimensional arrays, LBound/UBound, passing arrays and reading ranges into arrays.
  7. 11 MsgBox and InputBox: Talking to the User Show messages and ask questions in VBA with MsgBox and InputBox: button and icon constants, reading the result, Application.InputBox, cancel handling and validation.

Control Flow and Procedures

  1. 12 If...Then...Else in VBA Make decisions in VBA with If, ElseIf, Else, nested If, single-line If, IIf and comparison tips, including how to avoid non-short-circuit errors.
  2. 13 Select Case in VBA Replace long ElseIf ladders with Select Case: match values, lists, ranges, Is comparisons and text, use Case Else, and test conditions with Select Case True.
  3. 14 For...Next and For Each Loops in VBA Repeat work in VBA with For...Next (Step, counting down), nested loops, Exit For and For Each over arrays and collections, with loop-speed tips.
  4. 15 Do...Loop and While...Wend in VBA Use VBA Do While and Do Until loops, test conditions at the start or the end, exit with Exit Do, avoid infinite loops and use While...Wend and GoTo safely.
  5. 16 Procedures and Functions: Sub, Function and Arguments Write reusable VBA code with Sub and Function procedures: parameters, return values, ByVal vs ByRef, Optional and ParamArray, calling rules, Exit and UDFs.

Objects and Collections

  1. 17 Objects, Properties, Methods and the Object Model Understand VBA objects: properties, methods, collections, the Application-Workbook-Worksheet-Range hierarchy, qualifying references and the Object Browser.
  2. 18 With Blocks and Object Variables (Set, Nothing, Early vs Late Binding) Store objects in variables with Set, shorten code with With...End With, release with Nothing, and compare early and late binding with CreateObject.
  3. 19 Collections and the Dictionary Object in VBA Store and look up data with the VBA Collection and Scripting.Dictionary: add, remove, key lookups, Exists, For Each, counting duplicates and choosing the right container.

Working with Excel

  1. 20 Excel VBA: Workbooks and Worksheets Learn how to open, create, save and close workbooks and how to add, rename, copy, hide and loop over worksheets in Excel VBA, with safe patterns.
  2. 21 Excel VBA: Ranges and Cells Master the Range object in Excel VBA: reading and writing values, Cells, Offset, Resize, CurrentRegion, last row, Find, and fast loops over arrays.
  3. 22 Excel VBA: Formulas and Formatting Write formulas from VBA, use WorksheetFunction, apply number formats, fonts, borders, colors and conditional formatting, and build a tidy report header.
  4. 23 Excel VBA: Data, Tables and Charts Sort, filter, remove duplicates, build ListObjects, PivotTables and charts with Excel VBA. Includes patterns for dictionaries and grouping totals.

Working with Word and Outlook

  1. 24 Word Automation with VBA Automate Microsoft Word with VBA: create documents, work with Range and Selection, styles, tables, find and replace, bookmarks and template filling.
  2. 25 Outlook E-mail Automation with VBA Send, read and organize e-mail with Outlook VBA: MailItem, attachments, HTML bodies, folders, Items.Restrict, appointments and the security prompts to expect.
  3. 26 PowerPoint and Cross-Application Automation Create PowerPoint slides from Excel data with VBA, and learn early and late binding, CreateObject, GetObject and how Office programs talk to each other.

Forms, Events and Errors

  1. 27 VBA UserForms Basics Build your first VBA UserForm: add controls, show it modal or modeless, read values, handle Initialize and Click events, and pass data back to the sheet.
  2. 28 UserForm Controls and Input Validation Use ListBox, ComboBox, OptionButton, CheckBox, MultiPage and Frame controls in VBA UserForms, and validate input with Change, Exit and BeforeUpdate events.
  3. 29 VBA Events: Workbook, Worksheet and Application Run VBA automatically with Excel events: Workbook_Open, BeforeSave, Worksheet_Change, SelectionChange, OnTime, and application-level events with WithEvents.
  4. 30 VBA Error Handling and Debugging Handle run-time errors in VBA with On Error GoTo, Resume, the Err object and custom errors, and debug with breakpoints, Watch, Locals and the Immediate window.

Files, Databases and APIs

  1. 31 File System Operations in VBA Work with files and folders in VBA: Dir loops, FileSystemObject, copy, move, delete, create folders, build paths safely and let users pick files with dialogs.
  2. 32 Text and CSV Files in VBA Read and write text and CSV files in VBA with Open, Line Input, Print, FreeFile, TextStream and ADODB.Stream for UTF-8, and parse CSV data safely.
  3. 33 Databases and Web APIs from VBA Query Access, SQL Server and other databases from VBA with ADO, use parameters safely, copy a Recordset to a sheet, and call REST APIs with WinHTTP and JSON.

Projects and Practice

  1. 34 Project: Sales Report Builder A complete VBA project: read raw sales data, summarize by region with a dictionary, write a formatted report, add a chart and save a dated PDF, step by step.
  2. 35 Project: Contact Manager with a UserForm Build a contact manager in Excel VBA: a UserForm to add, search, edit and delete rows on a Contacts sheet, with validation, duplicate checks and a ListBox.
  3. 36 VBA Performance and Best Practices Make VBA macros fast and maintainable: turn off screen updating, use arrays, avoid Select, naming, Option Explicit, modules, constants, comments and security.
  4. 37 VBA Practice Exercises with Solutions Twelve VBA practice exercises across Excel, Word, Outlook, files, forms and error handling, with hints, solution outlines and runnable logic checks in JavaScript.