cs_pacadebord
Messages postés113Date d'inscriptionlundi 31 mars 2003StatutMembreDernière intervention19 décembre 20112 24 févr. 2010 à 09:38
Function NbUnAvantAutre(maPlage As Range, strVal1 As String, strVal2 As String, strVal3 As String)
Dim Cellule
For Each Cellule In maPlage
If Cellule = strVal3 Then
If Cellule.Offset(-1, 0) = strVal2 Then
If Cellule.Offset(-2, 0) = strVal1 Then
NbUnAvantAutre = NbUnAvantAutre + 1
End If
End If
End If
Next
End Function
Ex : =NbUnAvantAutre(A1:A10;"Paris";"Londres";"New York")
Molenn
Messages postés797Date d'inscriptionmardi 7 juin 2005StatutMembreDernière intervention23 février 20117 22 févr. 2010 à 14:42
Pour interroger 2 critères avec un nb.si, il faut passer par une colonne intermédiaire.
Dans ton cas, tu peux te contenter de mettre dans ta cellule B2 la formule suivante :
ET(A1"Paris";A2="Londre")
et de copier la formule sur toutes tes lignes (un double-clic suffit :) )
Ensuite, tu écris la formule suivante :
C1: =NB.SI(B:B;VRAI)
cs_pacadebord
Messages postés113Date d'inscriptionlundi 31 mars 2003StatutMembreDernière intervention19 décembre 20112 22 févr. 2010 à 15:31
Bonjour,
Vous pouvez coller ce bout de code dans un module :
Function NbParisAvantLondre(ByVal maPlage As Range)
Dim Cellule
For Each Cellule In maPlage
If Cellule = "Paris" Then
If Cellule.Offset(1, 0) = "Londre" Then
NbParisAvantLondre = NbParisAvantLondre + 1
End If
End If
Next
End Function
et utiliser la formule =NbParisAvantLondre() avec votre plage de cellules en paramètre.