XL 2010 Résolu par pierrejean If a plusieurs critères VBA

reinruof77

XLDnaute Occasionnel
re-bonjour

Voila j'ai ce code pour éviter les doubles saisie

Code:
If Application.WorksheetFunction.CountIf(Range("N:N"), TextBox4.Value) = 2 Then
      
    MsgBox "SAISIE DEJA EFFECTUER "
        End If

mais est t'il possible d'avoir plusieurs critères.
j'ais essayer ça
Code:
 If Application.WorksheetFunction.CountIf(Range("C:C"), ComboBox2.Value) = 2 Then
     If Application.WorksheetFunction.CountIf(Range("F:F"), DTPicker1.Value) = 2 Then
    If Application.WorksheetFunction.CountIf(Range("N:N"), TextBox4.Value) = 2 Then
      
    MsgBox "SAISIE DEJA EFFECTUER "
        End If
        End If
        End If

Mais cela ne fonctionne pas.:mad:

Merci de votre aide
(promis après j’arrête):)
 

Chris24

XLDnaute Impliqué
re chris24

cela ne fonctionne toujours pas
je te joint mon fichier car la je comprend pas?

Merci de ton aide

Je ne peux pas tester tu utilises un conrtôle Activex "dtPicker" non présent sur ma machine

Edit: Dtpicker renvoie une date, essaie ceci
Code:
Sub test()
Dim Nb As Boolean, Nb1 As Boolean, Nb2 As Boolean
Nb = Application.WorksheetFunction.CountIf(Range("C:C"), ComboBox2.Value > 1)
Nb1 = Application.WorksheetFunction.CountIf(Range("F:F"), Clng( DTPicker1) > 1)
Nb2 = Application.WorksheetFunction.CountIf(Range("n:n"), 'TexTbox4.Value > 1)
If  Nb And Nb1 And Nb2 = True Then
MsgBox "Ok ça marche"
Exit Sub
End If
End Sub
 
Dernière édition: