Skip to main content

Range.End property

Table of contents
  1. Syntax
  2. Parameters
  3. Example

Returns a Range object that represents the cell at the end of the region that contains the source range. Equivalent to pressing END+UP ARROW, END+DOWN ARROW, END+LEFT ARROW, or END+RIGHT ARROW. Read-only Range object.

Syntax

expression.End (Direction)

expression A variable that represents a Range object.

Parameters

Name Required/Optional Data type Description
Direction Required XlDirection The direction in which to move.

Example

The following example selects the cell at the top of column B in the region that contains cell B4.

Range("B4").End(xlUp).Select

The following example selects the cell at the end of row 4 in the region that contains cell B4.

Range("B4").End(xlToRight).Select

The following example extends the selection from cell B4 to the last cell in row four that contains data.

Worksheets("Sheet1").Activate 
Range("B4", Range("B4").End(xlToRight)).Select

The following example get the last blank cell of column A.

Dim LastBlankCell As Integer
LastBlankCell = Cells(Rows.count, 1).End(xlUp).Row + 1

Leave a comment

Your email address will not be published. Required fields are marked *

Format your code: <pre><code class="language-vba">place your code here</code></pre>