Applying Properties and Methods to an Object

You change attributes of an object by setting its properties. For example, you can set the Formula property of the Range object that refers to cell A1, which sets the formula in the cell.

You can also get the value of a property. For example, you can get the Value property of the Range object that refers to cell A1. This returns the value of cell A1 to your code, where you can use the value to make decisions or perform calculations.

Methods perform actions on objects. For example, you can save the active workbook by applying the SaveAs method to the Workbook object that refers to the active workbook. The difference between properties and methods is that properties have values you set or return, whereas methods are actions you want an object to perform.

Accessors are properties and methods you use to return an object. For example, the ActiveWorkbook property returns a Workbook object that refers to the active workbook, and the Range method returns a Range object that refers to a range of cells.

Note

In some object-oriented programming languages, distinguishing a property from a method is very straightforward. In Visual Basic, the distinction isn't so clear in some cases. For example, properties generally don't take arguments, but in Microsoft Excel the International property does take an argument. Don't worry about whether a keyword is a property or a method; instead, concentrate on finding the correct keyword for the task you want to accomplish.