Microsoft Office Tutorials and References
In Depth Information
19.2.2 Cells Property
or:
Range(Application.Names!TestRange)
to return this range.
The second syntax for the Range property is:
object .Range( Cell1 , Cell2 )
Here Cell1 is the cell in the upper-left corner of the range and Cell2 is the cell in the
lowerright corner, as in:
Range("D4", "F8")
Alternatively, Cell1 and Cell2 can be Range objects that represent a row or column. For
instance, the following returns the Range object that represents the second and third rows of the
active sheet:
Range(Rows(2), Rows(3))
It is important to note that when the Range property is applied to a Range object, all references are
relative to the upper-left corner cell in that range. For instance, if rng represents the second
column in the active sheet, then:
rng.Range("A2")
is the second cell in that column, and not cell A2 of the worksheet. Also, the expression:
rng.Range("B2")
represents the (absolute) cell C2, because this cell is in the second column and second row from
cell B1 (which is the upper-left cell in the range rng ).
19.2.2 Cells Property
The Excel object model does not have an official Cells collection nor a Cell object. Nevertheless,
the cells property acts as though it returns such a collection as a Range object. For instance, the
following code returns 8 :
Range("A1:B4").Cells.Count
Incidentally, Cells.Count returns 16,777,216 = 256 * 65536 .
The Cells property applies to the Application, Range, and Worksheet objects (and is global).
When applied to the Worksheet object, it returns the Range object that represents all of the cells
on the worksheet. Moreover, the following are equivalent:
Cells
Application.Cells
ActiveSheet.Cells
When applied to a Range object, the Cells property simply returns the same object, and hence does
nothing.
Search JabSto ::




Custom Search