Bonjour
J'ai créé un code mais je souhaiterais que Application.CountIf ne compte pas seulement un nom (ici CA) mais tous les noms compris dans une liste (ex: colonne P et Q).
voici mon code:
je souhaiterais que pour toute les fois à la place de "CA" il y ait une liste de nom (ex:liste dans une colonne)
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
Merci par avance
Manu