The Offset property

The Offset property provides another handy means for referring to ranges. This property, which operates on a Range object and returns another Range object, lets you refer to a cell that is a particular number of rows and columns away from another cell.

Like the Cells property, the Offset property takes two arguments. The first argument represents the number of rows to offset; the second represents the number of columns to offset.

The following expression refers to a cell one row below cell A1 and two columns to the right of cell A1. In other words, this refers to the cell commonly known as C2:

The Offset method can also use negative arguments. A negative row offset refers to a row above the range. A negative column offset refers to a column to the left of the range. The following example refers to cell A1:

And, as you may expect, you can use 0 as one or both of the arguments for Offset. The following expression refers to cell A1:

The Offset method is most useful when you use variables rather than actual values for the arguments. In Chapter 10, I present some examples that demonstrate this.

0 0

Post a comment