Sub
Max()
Start:
Dim
maxB
As
Variant
maxB = Clear
Worksheets(
"Tabelle1"
).Activate
Set
finden = Cells.Find(WorksheetFunction.Max(Range(
"B3:B500"
)), LookIn:=xlValues)
maxB = finden.Row
If
maxB = 2
Then
GoTo
Ende
Range(
"A"
& maxB &
":B"
& maxB).
Select
Selection.Copy
Dim
LetzteC
As
Long
Dim
LetzteE
As
Long
Dim
LetzteG
As
Long
With
Worksheets(
"Tabelle1"
)
LetzteC = .Cells(.Rows.Count,
"C"
).
End
(xlUp).Offset(1, 0).Row
LetzteE = .Cells(.Rows.Count,
"E"
).
End
(xlUp).Offset(1, 0).Row
LetzteG = .Cells(.Rows.Count,
"G"
).
End
(xlUp).Offset(1, 0).Row
End
With
EinfC = LetzteC
EinfE = LetzteE
EinfG = LetzteG
If
EinfC > 22
And
EinfE < 23
Then
GoTo
Lane_Mitte
If
EinfE > 22
And
EinfC < 23
Then
GoTo
Lane_Links
If
EinfE > 22
And
EinfC > 22
Then
GoTo
Lane_Rechts
If
Range(
"D2"
).Value < Range(
"F2"
).Value
Then
GoTo
Lane_Links
Else
GoTo
Lane_Mitte
End
If
Lane_Mitte:
Range(
"E"
& EinfE &
":F"
& EinfE).
Select
ActiveSheet.Paste
Range(
"A"
& maxB &
":B"
& maxB).
Select
Selection.Delete Shift:=xlUp
GoTo
Next_Line
Lane_Links:
Range(
"C"
& EinfC &
":D"
& EinfC).
Select
ActiveSheet.Paste
Range(
"A"
& maxB &
":B"
& maxB).
Select
Selection.Delete Shift:=xlUp
GoTo
Next_Line
Lane_Rechts:
If
EinfC > 22
And
EinfC > 22
And
EinfG > 22
Then
GoTo
Ende
Range(
"G"
& EinfG &
":H"
& EinfG).
Select
ActiveSheet.Paste
Range(
"A"
& maxB &
":B"
& maxB).
Select
Selection.Delete Shift:=xlUp
GoTo
Next_Line
Next_Line:
GoTo
Start
Ende:
End
End
Sub