Option
Explicit
Private
Sub
ZellenAusblenden()
Dim
lngLetzteZeile
As
Long
Dim
lngLaufZahl
As
Long
Dim
datVon
As
Date
Dim
datBis
As
Date
With
ActiveSheet
lngLetzteZeile = .Cells(.Cells.Rows.Count, 1).
End
(xlUp).Row
If
Not
IsDate(.Range(
"B8"
))
Or
Not
IsDate(.Range(
"D8"
))
Then
If
Not
IsDate(.Range(
"B8"
))
Then
MsgBox
"Die Zelle B8 enthält kein Datum! Das Programm wird abgebrochen"
, vbCritical,
"Fehler..."
ElseIf
Not
IsDate(.Range(
"D8"
))
Then
MsgBox
"Die Zelle D8 enthält kein Datum! Das Programm wird abgebrochen"
, vbCritical,
"Fehler..."
End
If
End
If
datVon = .Range(
"B8"
)
datBis = .Range(
"D8"
)
For
lngLaufZahl = 12
To
lngLetzteZeile
If
IsDate(.Cells(lngLaufZahl, 1))
Then
If
.Cells(lngLaufZahl, 1) < datVon
Or
.Cells(lngLaufZahl, 1) > datBis
Then
.Cells(lngLaufZahl, 1).EntireRow.Hidden =
True
Else
.Cells(lngLaufZahl, 1).EntireRow.Hidden =
False
End
If
Else
MsgBox
"Die Zelle A"
&
CStr
(lngLaufZahl) &
" enthält kein Datum!"
& Chr(10) _
&
"Das Programm kann keine der zugeordneten Aktionen durchführen."
, vbCritical,
"Fehler..."
End
If
Next
lngLaufZahl
End
With
End
Sub