Sub
Archivieren()
Dim
Wert3
As
String
Dim
Wert4
As
String
Wert3 = Sheets(
"ZP"
).Range(
"C8"
)
Wert4 = Sheets(
"ZP"
).Range(
"C9"
)
Set
ZP = Sheets(
"ZP"
)
Set
Archiv = Sheets(
"Archiv"
)
Sheets(
"Archiv"
).
Select
Range(
"A1"
).
Select
Kennzeichen:
On
Error
Resume
Next
If
IsEmpty(Sheets(
"ZP"
).Range(
"C8"
)) =
False
Then
Cells.Find(What:=Wert3, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=
False
, SearchFormat:=
False
).
Select
Selection.Offset(0, -2).
Select
GoTo
Copy
Else
GoTo
Behälter
If
Err.Number = 91
Then
GoTo
Behälter
End
If
End
If
On
Error
GoTo
0
Behälter:
On
Error
Resume
Next
If
IsEmpty(Sheets(
"ZP"
).Range(
"C9"
)) =
False
Then
Cells.Find(What:=Wert4, After:=ActiveCell, LookIn:=xlFormulas, _
LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
MatchCase:=
False
, SearchFormat:=
False
).
Select
Selection.Offset(0, -2).
Select
GoTo
Copy
If
Err.Number = 91
Then
GoTo
Search
End
If
End
If
On
Error
GoTo
0
Search:
If
Selection.Offset(0, 2).Value <>
""
Or
Selection.Offset(0, 3).Value <>
""
Then
Selection.Offset(1, 0).
Select
GoTo
Search
End
If
Copy:
Selection.Offset(0, 0).Value = Sheets(
"ZP"
).Range(
"G1"
).Value
Selection.Offset(0, 1).Value = Sheets(
"ZP"
).Range(
"C4"
).Value
Selection.Offset(0, 2).Value = Sheets(
"ZP"
).Range(
"C8"
).Value
Selection.Offset(0, 3).Value = Sheets(
"ZP"
).Range(
"C9"
).Value
Sheets(
"ZP"
).
Select
ActiveWorkbook.Save
End
Sub