Using Arrays to Specify Multiple Objects

Some of the methods that operate on objects in collections allow you to specify an array when you want to operate on a subset of objects in a collection. The following example calls the Worksheets method and the Delete method three times each.


Worksheets("sheet1").Delete
Worksheets("sheet2").Delete
Worksheets("sheet4").Delete

You can use an array to reduce this to one Worksheets method call and one Delete method call.


Worksheets(Array("sheet1", "sheet2", "sheet4")).Delete