vba · DOCS

List of Documents

With Statement

Learn how to use the VBA With statement to eliminate repetitive object references, improving code readability and maintainability. This guide covers basic syntax, practical examples, and best practices.

Close a Workbook

This page introduces how to close a workbook with VBA using the Close method.

Close Workbook Without Saving

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.

Open Workbook

Learn how to open a workbook using VBA with specific code examples.

Open Workbook as Read-Only

This page introduces how to open a workbook as read-only using VBA.

Add Worksheets

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.

Delete Worksheets

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.

Retrieve Worksheet

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.

Move Worksheets

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.

Retrieve Range Values

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.