Microsoft Office Tutorials and References
In Depth Information
worksheet. Employing a For…Each loop (loops are covered in Lesson 9) to edit every comment in
the Comments collection would make the task simple, because each comment would belong to the
Comments collection, and you’d be confident knowing you hit all comments without needing to
know what cells they are in.
A good rule of thumb in recognizing a Collections object is to notice that its
name ends with the letter “s,” as a pluralized form of its singular object item
name. Examples of this are the Names collection of individual Name objects, the
Charts collection of individual Chart objects, the Workbooks collection of
individual Workbook objects, and so on.
This lesson provided an overview of object-oriented programming. There are no programming
techniques to try based on the material in this lesson, but here are some important concepts to
keep in mind:
Excel is replete with objects, such as workbooks, worksheets, and cells, and each object has
its own set of properties that can be altered to suit your application project’s design.
If you should need to refer to an object’s container, such as when you refer to a worksheet in
another workbook, just use the object’s Parent property. All objects (except Application )
have a Parent property that is the object within which they are contained. For example,
if your active workbook object is Book2 but you want to refer to Sheet1 in Book1, you’d
precede the Sheet1 object with its parent Book1object name, like this: Workbooks(“Book1.
xlsm”).Worksheets(“Sheet1”).Range(“A1”).Value = “Hello”
The Application object indeed holds the highest order of Excel’s objects, but as you will
see, it also offers many useful methods and properties. The Application object provides the
ability to insert worksheet functions ( SUM , AVERAGE , VLOOKUP , and so on), as well as
commands to control Excel’s display options for worksheet gridlines, tabs, and window sizes.
There is no video to accompany this lesson.