Find the last used Cell on a Worksheet

by MD on 2010/01/10

Sub FindLastCell()

Dim LastColumn As Integer

Dim LastRow As Long

Dim LastCell As Range

   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

      'Search for any entry, by searching backwards by Columns.

            LastColumn = Cells.Find(What:="*", After:=[A1], _

                 SearchOrder:=xlByColumns, _

                 SearchDirection:=xlPrevious).Column

            MsgBox Cells(LastRow, LastColumn).Address

   End If

End Sub

You may also like:

Leave a Comment

Previous post:

Next post: