AW: habe es anders gelöst...
07.07.2011 13:02:38
Rudi
Hallo,
max. 20 Durchläufe:
Function LastRow( _
wks As Worksheet, _
Optional lngFirstRow As Long, _
Optional lngLastRow As Long) _
As Long
'letzte Zeile mit Inhalt
Dim lngTmp As Long, blnFound As Boolean
With Application
If .CountA(wks.Rows(wks.Rows.Count)) Then
LastRow = wks.Rows.Count: Exit Function
End If
If .CountA(wks.Cells) = 0 Then
LastRow = 0: Exit Function
End If
If lngFirstRow = 0 Then lngFirstRow = 1
If lngLastRow = 0 Then lngLastRow = wks.Rows.Count
lngTmp = (lngFirstRow + lngLastRow) / 2
If lngLastRow > lngFirstRow + 1 Then
If .CountA(wks.Range(.Rows(lngTmp), .Rows(lngLastRow))) Then _
lngFirstRow = lngTmp: blnFound = True
If Not blnFound And .CountA(wks.Range(.Rows(lngFirstRow), .Rows(lngTmp))) Then _
lngLastRow = lngTmp
LastRow wks, lngFirstRow, lngLastRow
End If
End With
LastRow = lngFirstRow
End Function
Gruß
Rudi