Private Function LastRow() As Long
LastRow = 0
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
End If
End Function
答案 0 :(得分:0)
您可以使用它来获取包含数据的列的最后一行
Dim LastRowOnColumn2 as Long
LastRowOnColumn2 = Activesheet.Cells(Activesheet.Rows.Count, 2).End(xlUp).Row