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 demonstrate 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
November 20, 2019

0 responses on "Methods and Properties"

    Leave a Message

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

    EC Analytics will help your business make better decisions by providing expert-level business intelligence (BI) services. Forecasting, strategy, optimization, performance analysis, trend analysis, customer analysis, budget planning, financial reporting and more. EC Analytics also offers Advanced Data Analytics training in corporate and retail.

    Social Media

    ECAnalytics-facebookECAnalytics_Linkedin

    Address:

    NM 23, SECTOR 14, OLD DLF COLONY,
    GURGAON (HARYANA)
    0124- 4601426

    EC Analytics Consulting @ 2019 ALL RIGHTS RESERVED