0
votes

Imagine that data :

 A1: 1  B1: 1  C1: 1  D1: 1
 A2: 2  B2: 2  C2: 2  D2: 2
 A3: 3  B3: 3  C3: 3  D3: 3

I want to select always the last line of the data . I know that code "ActiveSheet.Range("a1").End(xlDown).Select" however this only select the last cell of one column . How i can manage to select all the last data ?

3

3 Answers

0
votes

If you have a nice rectangular block of data, then:

Sub qwerty()
    Range("A1").CurrentRegion.Select
End Sub

will work. Even if the data is "jagged", you will get something that may be useful:

enter image description here

0
votes

What about this:

ActiveCell.SpecialCells(xlLastCell).Select
Range(Selection, Cells(ActiveCell.Row, 1)).Select

(I put my cursor inside the table, pressed Ctrl+End, followed by Shift+Home)

0
votes

It isn't pretty but this should select the last row as long as there aren't any blank cells in the row.

Range(Range("A1").End(xlDown), Range("A1").End(xlDown).End(xlToRight)).Select