Worksheets SheetRangeAValue End

After Excel executes this procedure, cell A1 on Sheet1 of the active workbook contains the value 934. (By the way, if the active workbook does not have a sheet named Sheet1, executing that macro will display an error message.)

Each object has its own set of properties, although some properties are common to many objects. For example, many (but not all) objects have a Visible property. Most objects also have a Name property.

Some object properties are read-only, which means that you can see the property's value, but you can't change it.

As I mention earlier in this chapter, a collection is also an object. This means that a collection also has properties. For example, you can determine how many workbooks are open by accessing the Worksheets collection's Count property. The following VBA procedure displays a message box that tells you how many workbooks are open:

Sub CountBooks()

MsgBox Workbooks.Count End Sub

0 0

Post a comment