22.4. Working with Worksheets

Most Workbooks you need to manipulate via VBA will contain one or more worksheets, so most procedures will need to work with worksheets — inserting them, deleting them, copying or moving them, or simply printing the appropriate range from them.

Each worksheet is represented by a Sheet object. The Sheet objects are contained within the Sheets collection.

22.4.1. Inserting a Worksheet

To insert a worksheet into a Workbook, use the Add method with the Sheets collection. The syntax is as follows:

expression.Add(Before, After, Count, Type)

The components of the syntax are as follows:

  • expression is a required expression that returns a Sheets collection. Often, you'll want to use the Sheets collection itself.

  • Before is ...

Get Mastering VBA for Microsoft Office 2007, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.