Microsoft Office Tutorials and References
In Depth Information
Properties and Methods
The fully qualified reference for the preceding example also includes the Application object,
as follows:
Most of the time, however, you can omit the Application object in your references; it is
assumed. If the Book1 object is the active workbook, you can even omit that object reference
and use this:
And — I think you know where I’m going with this — if Sheet1 is the active worksheet, you can
use an even simpler expression:
Contrary to what you might expect, Excel doesn’t have an object that refers to an
individual cell that is called Cell . A single cell is simply a Range object that happens to
consist of just one element.
Simply referring to objects (as in these examples) doesn’t do anything. To perform anything
meaningful, you must read or modify an object’s properties or specify a method to be used with
an object.
Properties and Methods
It’s easy to be overwhelmed with properties and methods; literally thousands are available. In this
section, I describe how to access properties and methods of objects.
Object properties
Every object has properties. For example, a Range object has a property called Value . You can
write VBA code to display the Value property or write VBA code to set the Value property to a
specific value. Here’s a procedure that uses the VBA MsgBox function to pop up a box that
displays the value in cell A1 on Sheet1 of the active workbook:
Sub ShowValue()
Msgbox Worksheets(“Sheet1”).Range(“A1”).Value
End Sub
Search JabSto ::

Custom Search