Using the End Property to Navigate within a Worksheet : Range Reference « Excel « VBA / Excel / Access / Word






Using the End Property to Navigate within a Worksheet

 
Sub ExperimentWithEnd() 
    Dim ws As Worksheet 
    Dim rg As Range 

    Set ws = ThisWorkbook.Worksheets(1) 
    Set rg = ws.Cells(1, 1) 

    ws.Cells(1, 8).Value = "rg.address = " & rg.Address 

    ws.Cells(2, 8).Value = "rg.End(xlDown).Address = " & rg.End(xlDown).Address 

    ws.Cells(3, 8).Value = "rg.End(xlDown).End(xlDown).Address = " & rg.End(xlDown).End(xlDown).Address 

    ws.Cells(4, 8).Value = "rg.End(xlToRight).Address = " & rg.End(xlToRight).Address 

    Set rg = Nothing 
    Set ws = Nothing 
End Sub 

 








Related examples in the same category

1.Reference a range by name
2.Refer to a range outside the active sheet by qualifying the range reference with a worksheet name from the active workbook
3.To refer to a range in a different workbook
4.Refer to an entire row
5.Refer to an entire column
6.Noncontiguous ranges
7.Select a range A1:A3
8.Activate the Range
9.Use disgonal cells to select a range
10.Use ActiveCell.End to select a range
11.Use the cell reference directly
12.Select a range by using the ActiveCell
13.Refer to the B2 cell in DataInput, while another workbook is active
14.Select Last Cell
15.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.
16.Use 0 as one or both of the arguments for Offset: expression refers to cell A1
17.returns a range object that represents the last non-empty cell in the same row
18.Using the Range Property to Refer to Groups of Cells
19.Specifying Individual Cells with the Cells Property