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
| Dim nABSSOG&, nABSINC2&, nABSINC1&
Private Sub Worksheet_Change(ByVal Target As Range)
Dim nABSSOG As Double
Dim nABSINC2 As Double
Dim nABSINC1 As Double
If Intersect([C9:M29], Target) Is Nothing Then Exit Sub
nABSSOG = Application.CountIf(Intersect([9:11], Target.EntireColumn), "CA")
nABSINC2 = Application.CountIf(Intersect([9:17], Target.EntireColumn), "CA")
nABSINC1 = Application.CountIf(Intersect([9:29], Target.EntireColumn), "CA")
If nABSSOG > 2 Then
MsgBox "Le nombre maximal de SOG absent est atteint !", vbCritical, "Absence"
Target.Interior.Color = RGB(255, 255, 255)
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
End If
If nABSINC2 > 4 Then
MsgBox "Le nombre maximal d'INC2 absent est atteint !", vbCritical, "Absence"
Target.Interior.Color = RGB(255, 255, 255)
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
End If
If nABSINC1 > 10 Then
MsgBox "Le nombre maximal d'INC1 est atteint !", vbCritical, "Absence"
Target.Interior.Color = RGB(255, 255, 255)
Application.EnableEvents = False
Target.ClearContents
Application.EnableEvents = True
End If
End Sub |
Partager