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
| Option Explicit
Sub Horaire()
Range("B3:H100").Select
Range("B3:H100").ClearContents
Dim HeureBase, HeureArrivee, DebutPause, FinPause, HeureDepart, TpsL As Single
Dim NumLigPH, NumLigPD, NumLigNP, NumLigBase As Integer
Dim i, j, k, l, m As Integer
NumLigPH = Range("W2").End(xlDown).Row
'MsgBox (NumLigPH) 'Ce code cherche la dernière ligne du tableau "PLAGE HORAIRE"
NumLigPD = Range("S2").End(xlDown).Row
'MsgBox (NumLigPD) 'Ce code cherche la dernière ligne du tableau "PAUSE DEJEUNER"
NumLigNP = Range("J2").End(xlDown).Row
'MsgBox (NumLigNP) 'Ce code cherche la dernière ligne du tableau avec le nombre de personne qui arrive
NumLigBase = Range("A11").End(xlDown).Row
'MsgBox (NumLigBase) 'Ce code cherche la dernière ligne du tableau que l'on cherche à automatiser
'Début de journée
For i = 3 To NumLigBase
HeureBase = Cells(i, 1)
'MsgBox HeureBase
For j = 2 To NumLigNP
HeureArrivee = Cells(j, 10)
'MsgBox HeureArrivee
For k = 11 To 17
If Cells(i, k - 9) = "" Then
Cells(i, k - 9) = Cells(i - 1, k - 9)
End If
If HeureBase = HeureArrivee Then
Cells(i, k - 9) = Cells(i - 1, k - 9) + Cells(j, k)
End If
For l = 2 To NumLigPH
TpsL = Cells(l, 25) - Cells(l, 24)
If HeureBase = HeureArrivee + TpsL Then
Cells(i, k - 9) = Cells(i - 1, k - 9) - Cells(j, k)
End If
Next l
Next k
Next j
Next i
'Fin de journée
For j = 2 To NumLigNP
HeureArrivee = Cells(j, 10)
For l = 2 To NumLigPD
For k = 11 To 17
If HeureArrivee = 7 Or HeureArrivee = 8 Or HeureArrivee = 8.5 Then
Cells(12, k - 9) = Cells(11, k - 9) - (Cells(2, k) + Cells(3, k) + Cells(4, k))
Cells(13, k - 9) = Cells(12, k - 9)
Cells(14, k - 9) = Cells(13, k - 9) + (Cells(2, k) + Cells(3, k) + Cells(4, k))
End If
Next k
For k = 11 To 17
If HeureArrivee = 9 Or HeureArrivee = 10 Then
Cells(14, k - 9) = Cells(13, k - 9) - (Cells(5, k) + Cells(6, k))
Cells(15, k - 9) = Cells(14, k - 9)
Cells(16, k - 9) = Cells(15, k - 9) + (Cells(5, k) + Cells(6, k))
End If
Next k
For k = 11 To 17
If HeureArrivee = 12 Then
Cells(22, k - 9) = Cells(21, k - 9) - Cells(7, k)
Cells(23, k - 9) = Cells(22, k - 9) + Cells(7, k)
End If
If HeureArrivee = 12.5 Then
Cells(23, k - 9) = Cells(22, k - 9) - Cells(8, k)
Cells(24, k - 9) = Cells(23, k - 9) + Cells(8, k)
End If
If HeureArrivee = 13 Then
Cells(24, k - 9) = Cells(23, k - 9) - Cells(9, k)
Cells(25, k - 9) = Cells(24, k - 9)
Cells(26, k - 9) = Cells(25, k - 9) + Cells(9, k)
End If
If HeureArrivee = 13.5 Then
Cells(25, k - 9) = Cells(24, k - 9) - Cells(10, k)
Cells(26, k - 9) = Cells(25, k - 9)
Cells(27, k - 9) = Cells(26, k - 9) + Cells(10, k)
End If
If HeureArrivee = 14 Then
Cells(26, k - 9) = Cells(25, k - 9) - Cells(11, k)
Cells(27, k - 9) = Cells(26, k - 9)
Cells(28, k - 9) = Cells(27, k - 9) + Cells(11, k)
End If
If HeureArrivee = 14.5 Then
Cells(27, k - 9) = Cells(26, k - 9) - Cells(12, k)
Cells(28, k - 9) = Cells(27, k - 9) + Cells(12, k)
End If
Next k
Next l
Next j
'Fin Pause
MsgBox ("Modifications terminées")
End Sub |
Partager