Objects, Properties & Methods

 

Excel VBA Property    |   Excel VBA Method    |   See all the properties and methods of an Object

In Excel VBA, objects, properties and methods are connected with a dot. Properties are something which an object has (they describe the object), while methods do something (they perform an action with an object).

Excel VBA Property

Let's take a look at an Excel VBA object and an Excel VBA property. We will use the Range object and the Formula property. The Range object is nothing more than a cell (or cells) on your worksheet. We already know from Excel that a cell can contain a formula.

1. Place the value 10 into cell A1.

2. Create a command button.

3. Add the line:

Range("B1").Formula = Range("A1") * 2


4. Execute the macro. This macro places the formula into cell B1 and the result will be calculated (20).

Excel VBA Method

Now let's take a look at an Excel VBA object and an Excel VBA method. We will use the Range object again and the ClearContents method.

1. Place the value 10 into cell A1.

2. Create a command button.

3. Add the line:

Range("A1").ClearContents


4. Execute the macro. Cell A1 is now empty!

That's how easy object-oriented programming in Excel Visual Basic is!

See all the properties and methods of an object.

The Range object has many more properties and methods. Want to see more?

1. Launch the Visual Basic Editor.

2. Type in: Range.

3. A list will appear showing you all the Excel VBA methods and properties of the Range object. The fingers are the properties and the green boxes are the methods of the Range object.

All properties and methods of the Range object

Did you find this information helpful? Show your appreciation, vote for us.

Go to Top: Objects, Properties and Methods    |    Go to Next Topic: Workbook and Worksheet

More about properties & methods, Login to the right >>
100 easy to follow Excel VBA examples. Limited time-offer: $39.00 but only $29.00. Ends on 29th February.