I'm partially there; I found and adapted this code from http://www.ozgrid.com/VBA/ExcelRanges.htm, and it gets me 3/4 of the way there:
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).Offset(0, -2).Address
End If
End Sub
The MsgBox displays the cell I need to doubleclick, but I can't figure out how to doubleclick it. Here's my latest attempt, which results in a "Run-Time error 424: Object Required". What am I doing wrong?
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
Cells(LastRow, LastColumn).Offset(0, -2).Address.DoubleClick
End If
End Sub
Bookmarks