The Worksheet Object

Much of your programming in Excel will deal directly with worksheets, as represented by the Worksheet object. In this section, I will cover the important aspects of manipulating worksheets and worksheet data.

Adding and Deleting Worksheets

To add a new worksheet to the Worksheets collection, use the Add method:

Dim MySheet As Excel.Worksheet
Set MySheet = Worksheets.Add(Before, After, Count)

The arguments are all optional; if omitted, one new worksheet is added before the currently active worksheet. You can use the Before or After argument to specify the existing worksheet before or after which the new one is to be placed. To add more than one worksheet, specify the desired number in Count. If Count is more than 1, the ...

Get Office® XP Development with VBA now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.