Using Default Properties and Methods

Many objects in Microsoft Excel have a default property or method. Visual Basic applies the default property or method to a given object to resolve an expression that would not be valid otherwise. For example, the following code would not be valid if the Range object did not have a default property, because you cannot set an object equal to a number.


Worksheets("Sheet1").Range("A1") = 3

Because the Range object's default property is the Value property, the preceding expression correctly sets the value of cell A1 on Sheet1 to the number 3. The preceding code is equivalent to the following code.


Worksheets("Sheet1").Range("A1").Value = 3

Although you can use the default property or method to save yourself some typing, this may create code that's difficult to debug and maintain. Using fully qualified expressions instead of using default properties and methods is highly recommended.