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
| If MsgBox("Etes-vous certain de vouloir mettre à jour l'ensemble des composants ?", vbYesNo, "Demande de confirmation") = vbYes Then
'Compter le nombre de composants
stp = False
i = 0
n = 3
While Not stp = True
If Cells(n, 1) <> "" Then
i = i + 1
Else
stp = True
End If
n = n + 1
Wend
Set Plage = Range("E3", "DE" & (2 + i))
Plage.Clear
'Mettre à jour pour chaque composant son plan de maintenance sur 2 ans
stp = False
n = 3
While Not stp = True
If Cells(n, 1) <> "" Then
'identifier le num du composant
numcomp = Cells(n, 3)
'identifier le type de péridicite
per = Sheets("Table_Composant").Cells(numcomp + 1, 7)
If per = "C" Then
d = 7
k = 1
Else
d = 1
k = 24
End If
'Mettre en mémoire les periodicite
t1 = Sheets("Table_Composant").Cells(numcomp + 1, 8)
t2 = Sheets("Table_Composant").Cells(numcomp + 1, 9)
t3 = Sheets("Table_Composant").Cells(numcomp + 1, 10)
t4 = Sheets("Table_Composant").Cells(numcomp + 1, 11)
t5 = Sheets("Table_Composant").Cells(numcomp + 1, 12)
'Remplir la ligne maintenance
For j = 5 To 109
If t1 <> "-" Then
'vérifier date mise en service > date de semaine et commencer après une périodicité
If (((Cells(2, j) - Cells(n, 4)) / d) * k) >= 1 Then
'comparer les dates
If (((Cells(2, j) - Cells(n, 4)) / d) * k) Mod t1 = 0 Then
Cells(n, j) = "T1"
End If
End If
End If
If t2 <> "-" Then
If (((Cells(2, j) - Cells(n, 4)) / d) * k) >= 1 Then
If (((Cells(2, j) - Cells(n, 4)) / d) * k) Mod t2 = 0 Then
Cells(n, j) = "T2"
End If
End If
End If
If t3 <> "-" Then
If (((Cells(2, j) - Cells(n, 4)) / d) * k) >= 1 Then
If (((Cells(2, j) - Cells(n, 4)) / d) * k) Mod t3 = 0 Then
Cells(n, j) = "T3"
End If
End If
End If
If t4 <> "-" Then
If (((Cells(2, j) - Cells(n, 4)) / d) * k) >= 1 Then
If (((Cells(2, j) - Cells(n, 4)) / d) * k) Mod t4 = 0 Then
Cells(n, j) = "T4"
End If
End If
End If
If t5 <> "-" Then
If (((Cells(2, j) - Cells(n, 4)) / d) * k) >= 1 Then
If (((Cells(2, j) - Cells(n, 4)) / d) * k) Mod t5 = 0 Then
Cells(n, j) = "T5"
End If
End If
End If
Next j
Else
stp = True
End If
n = n + 1
If (((Cells(2, j) - Cells(2, 5)) / 7)) = Cells(1, 4) Then
Cells(3, j).Select
End If
Wend
MsgBox ("Mise à jour réalisée" & Chr(10) & Chr(10) & ("Nombre de composants = " & i))
End If
End Sub |
Partager