Introduction to VBA
A learning site for Excel VBA. From basic usage of Excel VBA to practical samples, we explain it in an easy-to-understand manner.
Worksheet Operations
Learn how to add Excel worksheets with VBA. Covers Worksheets.Add basics, sheet naming rules and forbidden characters, positioning with Before/After, adding several sheets, and fixing duplicate-name errors, with code examples.
Learn how to delete Excel worksheets with VBA. Covers the Delete method, suppressing the confirmation prompt with DisplayAlerts, checking whether a sheet exists, deleting multiple sheets, and fixing cases where a sheet cannot be deleted, with code examples.
This guide explains how to retrieve a specific worksheet using VBA. It covers methods to specify by name, by index, and how to get the currently active worksheet.
Learn how to move worksheets to the start, the end, or before/after a specific sheet with the Excel VBA Move method, including multiple sheets, existence checks, and what happens when you omit the arguments.
Learn how to retrieve values from specific cells and ranges in a worksheet with VBA: the Range and Cells properties, working with 2D arrays, and practical examples.
Learn how to select sheets with the Excel VBA Select method: by name or index, multiple sheets at once, and adding sheets that match a condition. Also covers working without selecting.
Workbook Operations
This page introduces how to close a workbook with VBA using the Close method.
To close an Excel workbook without saving in VBA, pass SaveChanges:=False to the Close method. This article covers code examples for the active or a specific workbook, avoiding the confirmation dialog, and safely closing all other workbooks.
Learn how to open a workbook using VBA with specific code examples.
This page introduces how to open a workbook as read-only using VBA.
commands
This article explains how to retrieve the currently active sheet in Excel using VBA, along with examples. It also discusses the risks and precautions when using ActiveSheet.
Learn how to use the GoTo command in VBA to jump to specific points in your code.
Learn how to use VBA InStr and InStrRev functions to search for specific text within strings and get their position. Essential for string validation and data extraction.
Learn how to use the VBA Join function to combine array elements into a single string with a specified delimiter. The reverse of Split, perfect for data output and formatting.
Learn how to use the VBA Split function to divide strings by a delimiter into arrays, with examples for CSV and URLs, plus pitfalls such as empty strings (UBound is -1) and consecutive delimiters.
Learn how to use VBA Trim, LTrim, and RTrim to remove spaces from strings, why full-width spaces, tabs and line breaks are not removed, and how WorksheetFunction.Trim collapses inner spaces.
Tips
Do you experience screen shaking or frequent switching between processing mode and normal mode while running your created process? For those who do, we have a solution to easily solve the above problems and introduce code that can further accelerate your process.
By using arrays, you can store multiple pieces of data in a single variable. This page explains how to define and manipulate arrays in VBA.
Learn how to encode a string to Base64 in VBA without any reference settings, using ADODB.Stream and MSXML. Includes a UTF-8 version for non-ASCII text (BOM removed) and Base64URL conversion.
This article explains how to perform character escaping in VBA, such as double quotes and newline characters. It also describes the escape sequences used when including special characters in strings.
The VBA Collection object is a convenient data structure for flexibly managing multiple items. This article explains everything from basic usage to practical applications and comparisons with Dictionary.
Master VBA debugging techniques to efficiently find and fix bugs. Learn about Debug.Print, the Immediate Window, breakpoints, step execution, Watch Window, and other practical debugging methods.
The VBA Dictionary object is a powerful data structure for managing key-value pairs. This article explains everything from basic usage to practical applications in a beginner-friendly way.
Learn how to use the VBA Dir function to list, search, and work with files and folders. From basics to wildcards, subfolders, and FileSystemObject comparison—with practical code examples.
Learn how to remove empty-string ("") elements from a VBA array. Covers single-pass filtering with ReDim Preserve, avoiding errors when every element is empty, handling whitespace-only elements, and a reusable function with code examples.
A comprehensive guide to FileSystemObject (FSO) in VBA for file and folder operations. Learn file reading/writing, folder creation/deletion, file listing, and more with practical code examples.