Loading

Friday, January 30, 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()
   ThisWorkbook.ActiveSheet.Range("B3").ClearContents
End Sub

SHARE TWEET

Thank you for reading this article VBA Macro Excel Tutorial: Object Properties and Methods With URL https://x-tutorials.blogspot.com/2009/01/vba-macro-excel-tutorial-object.html. Also a time to read the other articles.

0 comments:

Write your comment for this article VBA Macro Excel Tutorial: Object Properties and Methods above!