Objects, Properties and Methods
- 02:17
Measuring, quantifying and chaging the property of a range object.
Downloads
No associated resources to download.
Transcript
Each object in Excel VBA has a set of predefined properties.
Think of the properties of an object as its characteristics.
An object's properties can be measured and quantified and can also be changed.
The object's property can be referred to in Excel VBA by typing the address of the object and then the property using VBA syntax to refer to the property of an object, we state the object, then a full stop or period, and then the object property is stated.
For example, the active sheet object has a name property in the line below the range object range, A1 has a value property.
A value or attribute can be assigned to the property by using the equal sign.
Here range object A1 has a value property and the value property is assigned the value of 10.
We can also apply a method to an object.
Methods are the actions that can be performed by an object or on an object.
The object method can be referred to by typing the address of the object, full stop or period.
And then the method, the save as method of the workbooks object has a number of arguments with one being mandatory.
The file name here, the active workbook object, has a save as method.
This line of code will instruct the active workbook to be saved with the file name.
My new file name Auto quick info is helpful here to understand the required arguments.
The clear method has no required arguments, and the code here instructs the contents of range object A1 to be cleared.