Methods and Properties

Share Now


Methods and Properties

Each object contains its own methods and properties.

A Property represents a built-in or user-defined characteristic of the object.  A method is an action that you perform with an object.  Below are examples of a method and a property for the Workbook Object:

Workbooks.Close

Close method close the active workbook

 

Workbooks.Count
Count property returns the number of workbooks that are currently opened
Some objects have default properties. For example, Range’s default property is Value.
The following yields the same outcome.

Range(“A1”) = 1    and     Range(“A1”).Value = 1
Here are examples on how to set and to get a Range property value:
The following sets the value of range A1 or Cells(1,1)  as “2005”.  It actually prints “2005” on A1.

Range(“A1”).Value = 2005
The following gets the value from range A1 or Cells(1,1).

X = Range(“A1”).Value
Method can be used with or without argument(s).  The following two examples demostrate this behavior.

Methods That Take No Arguments:

Worksheets(“Sheet”).Column(“A:B”).AutoFit
Methods That Take Arguments:

Worksheets(“Sheet1”).Range(“A1:A10”).Sort _
Worksheets(“Sheet1”).Range(“A1”)
Worksheets(“Sheet1”).Range(“A1”) is the Key (or column) to sort by.



Share Now
March 4, 2012

0 responses on "Methods and Properties"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Tableau Training in Delhi

    All Rights Reserved. EC Analytics Consulting 2014 - 2019.

    NM 23, Sector 14, OLD DLF Colony - Gurgaon (Haryana) India. 9582876837 | Privacy Policy

    Drop us a Query

    Call Us: +91 8826547882

    Drop us a Query