1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
| Sub Test()
Dim DernLigne, i As Long
Dim Day1, Month1, Year1, Day, Day2, Month2, Year2, Minute1, Hour1, Minute2, Hour2, Time As Long
DernLigne = ActiveSheet.Range("B" & Rows.Count).End(xlUp).Row
For i = 3 To DernLigne
If ActiveSheet.Range(Cells(i, 2)).Value = "OCCUPATION" Then
j = i - 1
If ActiveSheet.Range(Cells(j, 2)).Value = "LIBERATION" Then
Day1 = Left(Hi, 2)
Month1 = Right(Left(Hi, 5), 2)
Year1 = Right(Left(Hi, 10), 4)
Minute1 = Left(Right(Hi, 5), 2)
Hour1 = Left(Right(Hi, 8), 2)
Day2 = Left(Hj, 2)
Month2 = Right(Left(Hj, 5), 2)
Year2 = Right(Left(Hj, 10), 4)
Minute2 = Left(Right(Hj, 5), 2)
Hour2 = Left(Right(Hj, 8), 2)
If Month1 = Month2 Then
Day = Day2 - Day1
If Day = 0 Then
Time = ((60 - Minute1) + ((Hour2 - Hour1) * 60) + Minute2) / 60
ActiveSheet.Cells(Ii).Value = Time
ElseIf Day = 1 Then
Time = ((60 - Minute1) + ((24 - Hour1) * 60) + (Hour2 * 60) + Minute2) / 60
ActiveSheet.Cells(Ii).Value = Time
Else
Time = ((Day - 1) * 24) + ((60 - Minute1) + ((24 - Hour1) * 60) + (Hour2 * 60) + Minute2) / 60
ActiveSheet.Cells(Ii).Value = Time
End If
ElseIf Month1 = 1 Or Month1 = 3 Or Month1 = 5 Or Month1 = 7 Or Month1 = 8 Or Month1 = 10 Or Month1 = 12 Then
Day = Day2 + 31 - Day1
If Day = 1 Then
Time = ((60 - Minute1) + ((24 - Hour1) * 60) + (Hour2 * 60) + Minute2) / 60
ActiveSheet.Cells(Ii).Value = Time
Else
Time = ((Day - 1) * 24) + ((60 - Minute1) + ((24 - Hour1) * 60) + (Hour2 * 60) + Minute2) / 60
ActiveSheet.Cells(Ii).Value = Time
End If
ElseIf Month1 = 4 Or Month1 = 6 Or Month1 = 9 Or Month1 = 11 Then
Day = Day2 + 30 - Day1
If Day = 1 Then
Time = ((60 - Minute1) + ((24 - Hour1) * 60) + (Hour2 * 60) + Minute2) / 60
ActiveSheet.Cells(Ii).Value = Time
Else
Time = ((Day - 1) * 24) + ((60 - Minute1) + ((24 - Hour1) * 60) + (Hour2 * 60) + Minute2) / 60
ActiveSheet.Cells(Ii).Value = Time
End If
ElseIf Month1 = 2 Then
Day = Day2 + 28 - Day1
If Day = 1 Then
Time = ((60 - Minute1) + ((24 - Hour1) * 60) + (Hour2 * 60) + Minute2) / 60
ActiveSheet.Cells(Ii).Value = Time
Else
Time = ((Day - 1) * 24) + ((60 - Minute1) + ((24 - Hour1) * 60) + (Hour2 * 60) + Minute2) / 60
ActiveSheet.Cells(Ii).Value = Time
End If
End If
Else
End If
Else
End If
Next i
End Sub |
Partager