AW: Ein anderer Vorschlag - ganz ohne select
23.08.2007 20:08:00
Harry
Hi Larissa,
ein Beispiel:
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
'In ein Standardmodul:
'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Option Explicit
Public lngZ As Long
Public Sub datum()
Dim lngI As Long ', lngN As Long
lngI = Cells(Rows.Count, 1).End(xlUp).Row
marke1:
If lastdate(lngI) = "01.01.2007" Then '(If no "Balance" exists...)
Exit Sub
End If
MsgBox "gesuchtes Datum: " & lastdate(lngI), vbInformation, _
"Addresse für Zellbereich: " & lastrange(lngI)
Dim sel As Range
neu:
For Each sel In Range(lastrange(lngI))
If sel.Value "" Then
sel.EntireRow.Delete
GoTo neu
End If
Next
lngI = lngZ - 1
GoTo marke1
End Sub
Public Function lastdate(lngZeile As Long) As Date
Dim lngN As Long
For lngN = lngZeile To 1 Step -1
If Cells(lngN, 1).Value = "Balance" Then
lastdate = Cells(lngN, 2).Value
Exit Function
End If
Next lngN
lastdate = "01.01.2007" '(If no "Balance" exists...)
End Function
Public Function lastrange(lngZeile As Long) As Variant
Dim lngN As Long
For lngN = lngZeile To 1 Step -1
If Cells(lngN, 1).Value = "Balance" Then
lastrange = Range(Cells(lngN + 1, 2), Cells(lngZeile, 2)).Address
lngZ = lngN
Exit Function
End If
Next lngN
lastrange = Range(Cells(1, 2), Cells(lngZeile, 2)).Address '(If no "Balance" exists...)
End Function
Liebe Grüsse
Harry