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 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142
| Option Explicit
Dim celdepartphase, celdepartoption As Range
Dim mserror, existe, feuille As String
Dim nbligne, i, niveau, nb As Integer
Dim tc, toe As Long
Private Sub Worksheet_Activate()
Application.ScreenUpdating = False
'Sheets("Suivi financier cout reel").Activate
Set celdepartphase = Sheets("Suivi financier cout reel").Range("b4:z1000").Cells.Find("COUTS DE BASE")
Set celdepartphase = celdepartphase.Offset(0, -1)
Set celdepartphase = celdepartphase.Offset(3, 0)
Set celdepartoption = Sheets("Suivi financier cout reel").Range("b4:z1000").Cells.Find("OPTIONS CONTRACTUELLES")
Set celdepartoption = celdepartoption.Offset(0, -1)
Set celdepartoption = celdepartoption.Offset(3, 0)
tc = Sheets("Paramétrage").Range("e27").Value
toe = Sheets("Paramétrage").Range("e21").Value
For i = 0 To 10000
If celdepartphase.Offset(i, 7) = "" Then
Exit For
Else: nbligne = nbligne + 1
End If
Next i
For i = 0 To 10000
If celdepartoption.Offset(i, 7) = "" Then
Exit For
Else: nbligne = nbligne + 1
End If
Next i
nbligne = nbligne + 4
For i = 0 To nbligne
mserror = ""
If celdepartphase.Offset(i, 1) Like "*total*" Then
If celdepartphase.Offset(i, 7).Value < celdepartphase.Offset(i, 8).Value Then
mserror = "valeur saisie de la commande " & celdepartphase.Offset(i - 1, 2).Value & " est superieur au montant notifié"
niveau = 3
feuille = "Suivi financier cout reel"
Else:
If celdepartphase.Offset(i, 7).Value - celdepartphase.Offset(i, 7).Value * tc / 100 < celdepartphase.Offset(i, 8).Value Then
mserror = "valeur saisie de la commande " & celdepartphase.Offset(i - 1, 2).Value & " est bientot superieur arrive au montant notifié"
niveau = 46
feuille = "Suivi financier cout reel"
Else: GoTo 1
End If
End If
Else:
If celdepartphase.Offset(i, 3) Like "*total*" Then
If celdepartphase.Offset(i, 7).Value < celdepartphase.Offset(i, 8).Value Then
mserror = "valeur saisie " & celdepartphase.Offset(i, 3) & "de la commande " & celdepartphase.Offset(i - 1, 2).Value & " est superieur au montant notifié"
niveau = 3
feuille = "Suivi financier cout reel"
Else:
If celdepartphase.Offset(i, 7).Value - celdepartphase.Offset(i, 7).Value * toe / 100 < celdepartphase.Offset(i, 8).Value - Sheets("Paramétrage").Range("e21").Value Then
mserror = "valeur saisie " & celdepartphase.Offset(i, 3) & " de la commande " & celdepartphase.Offset(i - 1, 2).Value & " est bientot superieur montant notifié"
niveau = 46
feuille = "Suivi financier cout reel"
Else: GoTo 1
End If
End If
Else: GoTo 1
End If
End If
If mserror <> "" Then
recherche
inclure
End If
1: Next i
Application.ScreenUpdating = True
End Sub
Sub recherche()
nb = 0
existe = ""
Sheets("Alertes").Activate
For i = 0 To 10000
If Range("b8").Offset(i).Value = "" Then
Exit For
Else: nb = nb + 1
End If
Next i
For i = 0 To nb
If Range("d8").Offset(i).Value = mserror Then
Exit For
Else: existe = "non"
End If
Next i
End Sub
Sub inclure()
Sheets("alertes").Activate
If existe = "non" Then
Rows("8:8").Insert
With Range("b8")
.Value = Format(Date, "dd/mm/yyyy")
.Borders.Weight = xlThin
.Interior.ColorIndex = 2
.Font.Size = 12
End With
With Range("c8")
.Value = feuille
.Borders.Weight = xlThin
.Interior.ColorIndex = 2
.Font.Size = 12
End With
With Range("d8")
.Value = mserror
.Borders.Weight = xlThin
.Interior.ColorIndex = 2
.Font.Size = 12
End With
Range("e8").Font.ColorIndex = niveau
With Range("f8")
.Value = "non traité"
.Borders.Weight = xlThin
.Interior.ColorIndex = 2
.Font.Size = 12
End With
End If
End Sub
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
End Sub |
Partager