1、Rang.End找到最后一行
求第3列最后一行的行号
'第3列最后一行的行号
Sub findLastRow()
Dim r As Range
Set r = Cells(Rows.Count, 3).End(xlUp)
r.Select
MsgBox r.Row
End Sub
2、Range.SpecialCells找到最后一行
Sub findLastRow2()
Dim r As Range
Set r = Cells.SpecialCells(xlCellTypeLastCell)
MsgBox r.Row
End Sub
3、Range.Find找到最后一行(最优)
Sub findLastRow3()
Dim r As Range
Set r = Cells.Find("*", after:=Range("A1"), searchorder:=xlRows, searchdirection:=xlPrevious)
If r Is Nothing Then
MsgBox "表格没有数据"
Else
MsgBox r.Row
End If
End Sub