AW: Spalte ohne erste Zelle kopieren
16.03.2021 18:37:57
Nepumuk
Hallo Klaus,
so kommst du an die letzte benutzte Zeile:
Public Sub Test10()
Dim lngLastUsedRow As Long
If GetLastZell(Tabelle1.Columns("A:E"), lngLastUsedRow, 0, , False) Then
Call MsgBox("Letzte benutzte Zeile: " & CStr(lngLastUsedRow), vbInformation, "Information")
Else
Call MsgBox("Keine Zellen gefunden.", vbExclamation, "Hinweis")
End If
End Sub
Public Function GetLastZell( _
ByRef probjRange As Range, _
ByRef prlngLastRow As Long, _
ByRef prlngLastColumn As Long, _
Optional ByVal povblnReturnLastRow As Boolean = True, _
Optional ByVal povblnReturnLastColumn As Boolean = True) As Boolean
Dim objCell As Range
'Pruefen ob der gesamte Bereich nicht leer ist
If Application.CountBlank(probjRange) <> probjRange.Cells.CountLarge Then
With probjRange
If povblnReturnLastRow Then
Set objCell = .Find(What:="*", LookIn:=xlValues, Lookat:=xlWhole, _
SearchOrder:=xlByRows, SearchDirection:=xlPrevious)
prlngLastRow = objCell.Row
GetLastZell = True
End If
If povblnReturnLastColumn Then
Set objCell = .Find(What:="*", LookIn:=xlValues, Lookat:=xlWhole, _
SearchOrder:=xlByColumns, SearchDirection:=xlPrevious)
prlngLastColumn = objCell.Column
GetLastZell = True
End If
End With
Set objCell = Nothing
End If
End Function
Gruß
Nepumuk