0% found this document useful (0 votes)
276 views2 pages

VBA Excel Objects

VBA object use

Uploaded by

shaonaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
276 views2 pages

VBA Excel Objects

VBA object use

Uploaded by

shaonaa
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

7/12/2017 VBA Excel Objects

VBA - EXCEL OBJECTS


[Link] Copyright © [Link]

When programming using VBA, there are few important objects that a user would be dealing with.

Application Objects
Workbook Objects
Worksheet Objects
Range Objects

Application Objects
The Application object consists of the following −

Application-wide settings and options.


Methods that return top-level objects, such as ActiveCell, ActiveSheet, and so on.

Example

'Example 1 :
Set xlapp = CreateObject("[Link]")
[Link] "C:\[Link]"

'Example 2 :
[Link]("[Link]").Activate

'Example 3:
[Link] = True

Workbook Objects
The Workbook object is a member of the Workbooks collection and contains all the Workbook objects currently
open in Microsoft Excel.

Example

'Ex 1 : To close Workbooks


[Link]

'Ex 2 : To Add an Empty Work Book


[Link]

'Ex 3: To Open a Workbook


[Link] FileName:="[Link]", ReadOnly:=True

'Ex : 4 - To Activate WorkBooks


Workbooks("[Link]").Worksheets("Sheet1").Activate

[Link] 1/2
7/12/2017 VBA Excel Objects

Worksheet Objects
The Worksheet object is a member of the Worksheets collection and contains all the Worksheet objects in a
workbook.

Example

'Ex 1 : To make it Invisible


Worksheets(1).Visible = False

'Ex 2 : To protect an WorkSheet


Worksheets("Sheet1").Protect password:=strPassword, scenarios:=True

Range Objects
Range Objects represent a cell, a row, a column, or a selection of cells containing one or more continuous blocks
of cells.

'Ex 1 : To Put a value in the cell A5


Worksheets("Sheet1").Range("A5").Value = "5235"

'Ex 2 : To put a value in range of Cells


Worksheets("Sheet1").Range("A1:A4").Value = 5

[Link] 2/2

You might also like