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
| Public Sub mfc_alertes()
Dim nbLignes, i As Integer
Dim ref1 As String
Dim msDensite, msTemp, cons1, cons2, cons3, cons4 As Integer
Dim TabEssais As Object
Set TabEssais = Worksheets("DATA").Range("TableauEssais")
nbLignes = Worksheets("SAISIE").Range("C65536").End(xlUp).Row + 1
'--- On boucle sur toutes les modalités en cours de suivi
For i = 2 To nbLignes
msDensite = Range("E" & i).Value '--- Récupération de la densité du jour
msTemp = Range("F" & i).Value '--- Récupération de la température du jour
ref1 = Range("A" & i).Value '--- Récupération référence de la modalité
cons1 = WorksheetFunction.VLookup(ref1, TabEssais, 4, False) '--- Stockage Température de consigne
cons2 = WorksheetFunction.VLookup(ref1, TabEssais, 5, False) '--- Stockage densité de nutrition 1
cons3 = WorksheetFunction.VLookup(ref1, TabEssais, 6, False) '--- Stockage densité aération
cons4 = WorksheetFunction.VLookup(ref1, TabEssais, 7, False) '--- Stockage densité de nutrition 2
'--- Coloration des cellules aération et nutrion 1 en fonction de la densité
If (msDensite >= cons3 - 10 And msDensite <= cons3 + 10) Then
Range("J" & i & ":K" & i).Select
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 5287936
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ElseIf (msDensite < cons3 - 10 And msDensite > cons3 + 10) Then
Range("J" & i & ":K" & i).Select
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
ElseIf (msDensite > cons3 + 10 And msDensite - Range("H" & i).Value <= cons3 - 10) Then
Range("J" & i & ":K" & i).Select
With Selection.Value = "Anticiper"
With Selection.Interior
.Pattern = xlSolid
.PatternColorIndex = xlAutomatic
.Color = 49407
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Else
End If
Next i
End Sub |
Partager