Range.End 屬性 (Excel)Range.End property (Excel)

傳回 Range 物件,該物件代表包含來源範圍之區域結尾處的儲存格。Returns a Range object that represents the cell at the end of the region that contains the source range. 相當於按下 END + 向上鍵、END + 向下鍵、END + 向左鍵或 END + 向右鍵。Equivalent to pressing END+UP ARROW, END+DOWN ARROW, END+LEFT ARROW, or END+RIGHT ARROW. 唯讀 Range 物件。Read-only Range object.

語法Syntax

expression.End (Direction)expression.End (Direction)

expression 代表 Range 物件的變數。expression A variable that represents a Range object.

參數Parameters

名稱Name 必要/選用Required/Optional 資料類型Data type 描述Description
DirectionDirection 必要Required XlDirectionXlDirection 要移動的方向。The direction in which to move.

範例Example

本範例會在包含儲存格 B4 的區域中,選取 B 欄頂端的儲存格。This example selects the cell at the top of column B in the region that contains cell B4.

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

本範例會在包含儲存格 B4 的區域中,選取位於第 4 列末端的儲存格。This example selects the cell at the end of row 4 in the region that contains cell B4.

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

本範例會將選取範圍從儲存格 B4 延伸到第四列最後一個包含資料的儲存格。This 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

支援和意見反應Support and feedback

有關於 Office VBA 或這份文件的問題或意見反應嗎?Have questions or feedback about Office VBA or this documentation? 如需取得支援服務並提供意見反應的相關指導,請參閱 Office VBA 支援與意見反應Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.