Wrapping Your Mind around Collections

Vertex42 The Excel Nexus

Professional Excel Templates

Get Instant Access

Collections are another key concept in VBA programming. A collection is a group of objects of the same type. And to add to the confusion, a collection is itself an object.

Here are a few examples of commonly used collections:

i Workbooks: A collection of all currently open Workbook objects i Worksheets: A collection of all Worksheet objects contained in a particular Workbook object i Charts: A collection of all Chart objects (chart sheets) contained in a particular Workbook object i Sheets: A collection of all sheets (regardless of their type) contained in a particular Workbook object

You may notice that collection names are all plural, which makes sense (at least I hope).

^fBEH

^fBEH

Visualizing objects

Excel's Help system displays the complete Excel object model graphically. Locating this diagram varies, depending on the version of Excel you have. For Excel 2003, follow these steps:

1. Activate the VBE.

2. Type Object Model in the Help box (located to the right of the menu bar).

The Search Results appear in the task pane.

3. Click Microsoft Excel Object model. You see the diagram shown here.

Office Vba Object Model

Was this article helpful?

0 0

Post a comment