excel vba 快速获取某工作表最后行数(首列不为空值)

Function getlastcell(mysheet As String, Optional startrow As Integer) As Integer
  Sheets(mysheet).Select
      rowcountinu = False
  If startrow = 0 Then
     startrow = 2
  End If
  For i = startrow To startrow + 2000
    If Trim(Cells(i, 1).Text) = "" Then
             getlastcell = i
          rowcountinu = False
       Exit Function
    End If
  Next
  rowcountinu = True
  getlastcell = i - 1 '临时方法,用2000作为分界和首次未结束标记
End Function

你可能感兴趣的:(excel vba 快速获取某工作表最后行数(首列不为空值))