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
| Sub Journee()
Dim ligne, colonne, lfin, cfin, cref, j, parite1, parite2 As Integer
Dim CMax, Max, CMin, Min, Tarr, compare, tret, amplimax
'Déclaration des hypothèses
tret = Format(Worksheets("journ").Cells(2, 2), "hh:nn:ss")
amplimax = Format(Worksheets("journ").Cells(3, 2), "hh:nn:ss")
'Prise en compte des dimensions du tableau
lfin = Cells(65335, 2).End(xlUp).Row
cfin = Cells(7, 256).End(xlToLeft).Column
'initialisation
ligne = 9
j = 1
'début de boucle
For ligne = 9 To lfin
If Cells(ligne, 23).Value <> 1 Then
parite2 = Cells(ligne, 1).Value
If Worksheets("journ").Cells(ligne, 4) = "" Then
Max = "00:00:00"
Else
Max = Format(Worksheets("journ").Cells(ligne, 4), "hh:nn:ss")
End If
If Worksheets("journ").Cells(ligne, cfin) = "" Then
Min = "24:59:59"
Else
Min = Format(Worksheets("journ").Cells(ligne, cfin), "hh:nn:ss")
End If
CMax = 4
CMin = cfin
'boucles pour trouver Max et Min
For colonne = 5 To cfin
If Worksheets("journ").Cells(ligne, colonne) = "" Then
compare = "00:00:00"
Else
compare = Format(Worksheets("journ").Cells(ligne, colonne), "hh:nn:ss")
If DateDiff("s", Max, compare) > 0 Then
Max = compare
CMax = colonne
End If
End If
Next
For colonne = cfin - 1 To 4 Step -1
If Worksheets("journ").Cells(ligne, colonne) = "" Then
compare = "00:00:00"
Else
compare = Format(Worksheets("journ").Cells(ligne, colonne), "hh:nn:ss")
If DateDiff("s", Min, compare) < 0 Then
Min = compare
CMin = colonne
End If
End If
Next
'Tests pour remplir les colonnes > 24
If ligne > 9 Then
If parite2 <> parite1 Then
If CMin = cref Then
'If DateDiff("s", Min, Tarr + tret) > 0 Then
If Min > Tarr + tret Then
j = j + 1
'choix de la ligne 27 pour faire un test sans écraser les données de la colonne 24
Cells(ligne, 27) = j
'Récupérer le n° de colonne et la valeur Max et la parité
Tarr = Max
cref = CMax
'parite1 = Cells(ligne, 1).Value
End If
End If
End If
End If
'Récupérer le n° de colonne et la valeur Max et la parité
Tarr = Max
cref = CMax
parite1 = Cells(ligne, 1).Value
End If
Next ligne
End Sub |
Partager