Option
Explicit
Sub
tiere()
Dim
strTier
As
String
Dim
lngLetzteQuellZeile
As
Long
Dim
lngQuellLaufZahl
As
Long
Dim
lngLetzteSuchZeile
As
Long
Dim
lngSuchLaufZahl
As
Long
With
ThisWorkbook
With
.Sheets(
"Deklaration"
)
lngLetzteSuchZeile = .Cells(.Cells.Rows.Count, 1).
End
(xlUp).Row
End
With
With
.Sheets(
"Tiere"
)
lngLetzteQuellZeile = .Cells(.Cells.Rows.Count, 1).
End
(xlUp).Row
For
lngQuellLaufZahl = 1
To
lngLetzteQuellZeile
strTier = .Cells(lngQuellLaufZahl, 1)
If
strTier <>
""
Then
With
ThisWorkbook.Sheets(
"Deklaration"
)
For
lngSuchLaufZahl = 1
To
lngLetzteSuchZeile
If
.Cells(lngSuchLaufZahl, 1) = strTier
Then
ThisWorkbook.Sheets(
"Tiere"
).Cells(lngQuellLaufZahl, 2) = .Cells(lngSuchLaufZahl, 2)
ElseIf
.Cells(lngSuchLaufZahl, 3) = strTier
Then
ThisWorkbook.Sheets(
"Tiere"
).Cells(lngQuellLaufZahl, 2) = .Cells(lngSuchLaufZahl, 4)
End
If
Next
lngSuchLaufZahl
End
With
End
If
Next
End
With
End
With
End
Sub