Sub
KFZAufrufen()
Dim
sh
As
Worksheet, arr, lastErow
As
Long
, matchCel
As
Range
Set
sh = ActiveSheet
arr = sh.Range(
"E2:E9"
).Value
lastErow = sh.Range(
"C"
& sh.Rows.Count).
End
(xlUp).Row + 1
If
Range(
"E2"
) =
""
Then
MsgBox
"Wählen Sie ein KFZ aus!"
Range(
"E2"
).
Select
Exit
Sub
End
If
If
lastErow < 13
Then
lastErow = 13
Set
matchCel = sh.Range(
"C13:C"
& lastErow - 1).Find(WHAT:=sh.Range(
"E2"
).Value, LookIn:=xlValues, Lookat:=xlWhole, MatchCase:=
False
)
If
Not
matchCel
Is
Nothing
Then
MsgBox sh.Range(
"E2"
).Value &
" wurde gefunden in "
& matchCel.Address &
"."
sh.Range(
"E3:E9"
).Value = Application.Transpose(sh.Range(matchCel.Offset(0, 1), matchCel.Offset(0, 7)).Value)
Exit
Sub
End
If
sh.Range(
"C"
& lastErow).Resize(1, UBound(arr)).Value = Application.Transpose(arr)
sh.Range(
"E2:E9"
).ClearContents
End
Sub