Using the Top Left and Bottom Right Corners of a Selection to Specify a Range

There are two acceptable syntaxes for the Range command. To specify a rectangular range in the first syntax, you specify the complete range reference just as you would in a formula in Excel:

Range("A1:B5").Select

In the alternative syntax, you specify the top-left corner and bottom-right corner of the desired rectangular range. In this syntax, the equivalent statement might be Range("A1", "B5").Select

For either corner, you can substitute a named range, the Cells function, or the ActiveCell property. This line of code selects the rectangular range from A1 to the active cell:

Range("A1", ActiveCell).Select

The following statement would select from the active cell to five rows below the active cell and two columns to the right:

Range(ActiveCell, ActiveCell.Offset(5, 2)).Select

0 0

Post a comment