Range Property of a Range Object

The Range property is normally used as a property of the Worksheet object. You can also use the Range property of the Range object. In this case, it acts as a reference relative to the Range object itself. The following is a reference to the D4 cell:

If you consider a virtual worksheet that has C3 as the top left-hand cell, and B2 is one column across and one row down on the virtual worksheet, you arrive at D4 on the real worksheet.

You will see this "Range in a Range" technique used in code generated by the macro recorder when relative recording is used (discussed in Chapter 2). For example, the following code was recorded when the active cell and the four cells to its right were selected while recording relatively:


Because the preceding code is obviously very confusing, it is best to avoid this type of referencing. The Cells property is a much better way to reference relatively.

0 0

Post a comment