Lecture 15
Lecture 15
Introduction to Computer
Programming for Engineering
1
2/17/2012
2
2/17/2012
3
2/17/2012
Application Object
• a collection of all
Workbooks
Workbook objects
• a collection of all
Windows
Window objects
• a collection of all
AddIns
AddIn objects
Workbook Object
• a collection of
Worksheets
Worksheet objects
• a collection of Chart
Charts
objects
• a collection of Name
Names
objects
4
2/17/2012
COLLECTIONS
Collections
a collection is itself an
object.
5
2/17/2012
Collections
Collections
Worksheets(“Sheet1”)
6
2/17/2012
OBJECT REFERENCING
Object Referencing
7
2/17/2012
Object Referencing
Range(“A1”)
Object Referencing
Worksheets(“Sheet1”).Range(“A1”)
8
2/17/2012
Object Referencing
Workbooks(“Book1”).Worksheets(“Sheet1
”).Range(“A1”)
Object Referencing
Application.Workbooks(“Book1”).Workshe
ets(“Sheet1”).Range(“A1”)
9
2/17/2012
EXCEL APPLICATION
OBJECT
10
2/17/2012
11
2/17/2012
CELL RANGES
12
2/17/2012
Range Object
13
2/17/2012
Range Property
Syntax:
◦ object.Range(cell1)
◦ object.Range(cell1, cell2)
◦ object.Range(cell1:cell2)
◦ object.Range(NamedRange)
Cells Property
Another way to reference a range is to
use the Cells property. You can use the
Cells property, like the Range property, on
Worksheet objects and Range objects.
Syntaxes:
◦ object.Cells(rowIndex, columnIndex)
◦ object.Cells(rowIndex)
◦ object.Cells
14
2/17/2012
Offset Property
Offset Property
Syntax:
◦ object.Offset(rowOffset, columnOffset)
15