PDA

View Full Version : [SOLVED] Select the lastrow using the active cell



khalid79m
11-27-2008, 03:06 PM
How can I select a range using the activecell & lastrow or offset & lastrow?

:think:

Bob Phillips
11-27-2008, 03:52 PM
With ActiveCell

.Resize(.End(xlDown).Row - .Row + 1).Select
End With

n8Mills
11-28-2008, 02:11 AM
...or perhaps:

Range(ActiveCell, ActiveCell.End(xlDown)).Select

...or If you want to use a variable you can do this:

Dim lastRow as Long

lastRow = ActiveCell.End(xlDown).Row

Range(ActiveCell, ActiveCell.Offset(lastRow, 0)).Select

khalid79m
11-28-2008, 02:24 AM
I need to use the activecel and lastrow, but the lastrow based on column A if that makes sense




Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row

range("b2:b" & lastrow)


but i want be able to say




Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row

Activecell & Lastrow

Bob Phillips
11-28-2008, 02:35 AM
The clues were all there



Dim LastRow As Long

LastRow = Cells(Rows.Count, "A").End(xlUp).Row
With ActiveCell

.Resize(LastRow - .Row + 1).Select
End With

khalid79m
11-28-2008, 06:21 AM
thanks, again for all the help

n8Mills
11-28-2008, 11:23 AM
...or this way:

Dim LastRow As Long

LastRow = Range("A65536").End(xlUp).Row

Range(ActiveCell.Address & "," & Range("B" & LastRow).Address).Select
... for those of us who have never touched .Resize or .Count before.

Bob Phillips
11-28-2008, 12:59 PM
...or this way:

Dim LastRow As Long

LastRow = Range("A65536").End(xlUp).Row

Range(ActiveCell.Address & "," & Range("B" & LastRow).Address).Select
... for those of us who have never touched .Resize or .Count before.

You might want to try that!