Referencing an objects properties and methods

We reference the properties and methods of an object by using the dot notation (.), it is written in the following notation:


Where Object is a reference to an object, such as Range or Workbook, and Identifier could be a valid property or method, such as Name or ClearContents.


Range ("my_ceNs").ClearContents is a reference to the ClearContents method of the Range object my_cells. Worksheets("that_sheet").Range ("C1").value = 6.

In this example, property value 6 has been set in the cell range C1, in the worksheet called that_sheet of the Worksheets collection (see next section). Note that in this example, the worksheet reference has been included. When you need to refer to a specific worksheet, you have to include the worksheet reference. Otherwise, the active worksheet reference would be taken.

Charts ("Chart1").PlotArea.Interior.ColorIndex = 3.

In this example, the colour of the PlotArea of chartl of the charts collection (see next section) has been set to red (Colorlndex = 3).

0 0

Post a comment