Kollisionsprüfung
10.02.2020 16:27:13
Ben
ich möchte zwei Datumsangaben auf ein Kollision mit einander vergleichen. Dabei soll bei eintreffen der folgenden drei Fälle ein MsgBox ausgegeben werden und die Zelle eingefärbt werden. Die zu vergleichenden Datensätze i und n sind mit folgenden Variablen bestimmt ( der Einfachheit halber zähle ich mit i und n später durch):
Ai = Einsatz i Anfangsdatum
Ei = Einsatz i Enddatum
An = Einsatz n Anfangsdatum
En = Einsatz n Enddatum
1. Fall: n kollidiert mit i von vorne: An 2. Fall: n liegt innerhalb von i : Ai
For i = 3 To lastE
For n = 4 To lastE
Ai = .Cells(i, 8).Value
Ei = .Cells(i, 9).Value
An = .Cells(n, 8).Value
En = .Cells(n, 9).Value
If .Cells(i, 3).Value = .Cells(n, 3).Value Then
'1. fall
If An .Cells(n, 2).Value _
Then
MsgBox "Einsatz " & .Cells(i, 2).Value & " kollidiert mit Einsatz "
.Cells(i, 2).Interior.ColorIndex = 46
.Cells(n, 2).Interior.ColorIndex = 46
GoTo sprung
End If
'2. fall
If Ai .Cells(n, 2). _
Value Then
MsgBox "Einsatz " & .Cells(i, 2).Value & " kollidiert mit Einsatz "
.Cells(i, 2).Interior.ColorIndex = 46
.Cells(n, 2).Interior.ColorIndex = 46
GoTo sprung
End If
'3. fall
If Ai .Cells(n, 2).Value _
Then
MsgBox "Einsatz " & .Cells(i, 2).Value & " kollidiert mit Einsatz "
.Cells(i, 2).Interior.ColorIndex = 46
.Cells(n, 2).Interior.ColorIndex = 46
GoTo sprung
End If
End If
sprung: n = n + 1
Next n
Next i