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
|
Option Explicit
Sub TriDelai()
Dim I As Integer, J As Integer
Dim AireDelai As Range
Dim TableDelai As Variant
Dim TempsEnMinutes As Long
Set AireDelai = Range("t_Delais[Temps]")
Range(AireDelai.Offset(0, 1), AireDelai.Offset(0, 3)).Clear
For I = 1 To AireDelai.Count
TempsEnMinutes = 0
TableDelai = Split(AireDelai(I), " ")
If UBound(TableDelai) > 0 Then
For J = LBound(TableDelai) To UBound(TableDelai)
If InStr(1, TableDelai(J), "days", vbTextCompare) > 0 Then
AireDelai(I).Offset(0, 1) = TableDelai(J - 1)
TempsEnMinutes = TableDelai(J - 1) * 24 * 60
End If
If InStr(1, TableDelai(J), "hrs", vbTextCompare) > 0 Then
AireDelai(I).Offset(0, 2) = TableDelai(J - 1)
TempsEnMinutes = TempsEnMinutes + TableDelai(J - 1) * 60
End If
If InStr(1, TableDelai(J), "mins", vbTextCompare) > 0 Then
AireDelai(I).Offset(0, 3) = TableDelai(J - 1)
TempsEnMinutes = TempsEnMinutes + TableDelai(J - 1)
End If
AireDelai(I).Offset(0, 4) = TempsEnMinutes
Next J
Else
End If
Next I
With Sheets("Feuil1").ListObjects("t_Delais")
.Sort.SortFields.Clear
.Sort.SortFields.Add2 Key:=Range("t_Delais[Total]"), SortOn:=xlSortOnValues, Order:=xlAscending, DataOption:=xlSortNormal
With .Sort
.Header = xlYes
.MatchCase = False
.Orientation = xlTopToBottom
.SortMethod = xlPinYin
.Apply
End With
End With
Set AireDelai = Nothing
End Sub |
Partager