Saturday, January 31, 2009

VBA Macro Excel Tutorial: Object Properties and Methods

Object Properties
Property is a piece of information that is associated with an object (for example, the color of you hair). Where "hair" is the object and "color" is the property. Some objects are read-only, meaning that you can read the value but you can't change it. Others are read-write, where you can read and change the properties.

For example, the following codes will set value of cell B3 to "VBA Macro Excel".

ActiveWorkbook.ActiveSheet.Range("B3").Value = "VBA Macro Excel"

And this code bellow will display the value of cell B3

MsgBox ActiveWorkbook.ActiveSheet.Range("B3").Value

Object Methods

A method is an action that the object can perform. For example, methods for a car would include "speed up", "speed down", and "stop".

If you execute this code, cell B3 on active sheet will be empty.

Sub clearCellB3()
End Sub

No comments:

Post a Comment