Defining a Range

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to define the last used row on a worksheet. I could use
"SpecialCells(xlLastCell)" however this also includes extra rows that were
used previously but are now empty.

I think there is a function that gives the last cell or row in a block/table
of cells but I can't find it.

Any ideas?

Kaval
 
Kaval

Sub FindLastRow()
Dim LastRow As Long
If WorksheetFunction.CountA(Cells) > 0 Then
'Search for any entry, by searching backwards by Rows.
LastRow = Cells.Find(What:="*", after:=[A1], _
SearchOrder:=xlByRows, _
searchdirection:=xlPrevious).Row
MsgBox LastRow
End If
End Sub

Gord Dibben Excel MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top