Cells(1,1)

  • Thread starter Thread starter pcw
  • Start date Start date
P

pcw

I have often seen the following ... Cells(1,1)

What does it mean? Is it referencing first row and column?
 
It means the first row and first column of its parent object.

By default, the parent object is the Activesheet, so

Cells(1, 1).Value = 1

will place the value 1 in the ActiveSheet's cell A1.

Similarly,

Range("J10:K100").Cells(1, 1) = 1

would place 1 in the cell in the first row and first column of the range
J10:K100 of the ActiveSheet, or cell J10.


See the entry for Range Object in XL/VBA Help for more.
 
JE said:
. . . Similarly,

Range("J10:K100").Cells(1, 1) = 1

would place 1 in the cell in the first row and first column of the range
J10:K100 of the ActiveSheet, or cell J10. . . .

Although the .Cells is superfluous and slows things down as contrasted with

Range("J10:K100")(1, 1) = 1

Alan Beban
 
Alan Beban said:
Although the .Cells is superfluous and slows things down as contrasted with

Range("J10:K100")(1, 1) = 1

True, but the OP wanted to know about .Cells(1, 1), not .Item(1, 1)
 
Back
Top