Ceci est une page optimisée pour les mobiles. Cliquez sur ce texte pour afficher la vraie page.

XL 2016 formule matricielle

SPARKLETOF

XLDnaute Junior
Bonjour,

j'ai un fichier excel dans lequel se trouve des infos concernant l'année, n° de dossier, n° échantillons et type d'analyses.
Je cherche un moyen d'obtenir le nombre de dossiers par type d'analyses et par année....
J'ai une formule en matricielle qui me sert compter le nombre de dossiers différents pour une année mais en ajoutant ces conditions je suis perdu...
Quelqu'un peut m'aider ?
Je joins le fichier (un exemple, car le miens possède environ 20000 lignes...)
Merci par avance.
Pour info je suis avec Excel 2016
SKF
 

Pièces jointes

  • Dossiers analyses.xlsx
    10.1 KB · Affichages: 26

SPARKLETOF

XLDnaute Junior
Merci beaucoup, je teste çà sur mon fichier original et je donne des nouvelles !
Tout fonctionne, en revanche, cela demande pas mal de ressource et çà rame pas mal du coup !
 
Dernière édition:

vgendron

XLDnaute Barbatruc
Hello
un essai par macro
VB:
Sub Compter()

Dim tablo() As Variant
Set dico = CreateObject("Scripting.dictionary")

With Sheets("Feuil2")
    Fin = .UsedRange.Rows.Count
    tablo = .Range("A2:D" & Fin).Value
End With

For i = LBound(tablo, 1) To UBound(tablo, 1)
    If Not dico.exists(tablo(i, 2) & "-" & tablo(i, 1)) Then
        dico.Add tablo(i, 2) & "-" & tablo(i, 1), tablo(i, 4)
    End If
   
Next i

'Recherche 1==>Eau - 2013
TypeSol = "eau"
annee = 2013
Rech = 0
For Each ele In dico.keys
    If CInt(Split(ele, "-")(1)) = annee And UCase(dico.Item(ele)) = UCase(TypeSol) Then
        Rech = Rech + 1
    End If
Next ele
Range("G3") = Rech

'Recherche 2==>Eau - 2014
TypeSol = "eau"
annee = 2014
Rech = 0
For Each ele In dico.keys
    If CInt(Split(ele, "-")(1)) = annee And UCase(dico.Item(ele)) = UCase(TypeSol) Then
        Rech = Rech + 1
    End If
Next ele
Range("H3") = Rech

'Recherche 3==>Sable - 2013
TypeSol = "Sable"
annee = 2013
Rech = 0
For Each ele In dico.keys
    If CInt(Split(ele, "-")(1)) = annee And UCase(dico.Item(ele)) = UCase(TypeSol) Then
        Rech = Rech + 1
    End If
Next ele
Range("G4") = Rech

'Recherche 4==>Sable - 2014
TypeSol = "Sable"
annee = 2014
Rech = 0
For Each ele In dico.keys
    If CInt(Split(ele, "-")(1)) = annee And UCase(dico.Item(ele)) = UCase(TypeSol) Then
        Rech = Rech + 1
    End If
Next ele
Range("H4") = Rech

'Recherche 3==>Terre- 2013
TypeSol = "Terre"
annee = 2013
Rech = 0
For Each ele In dico.keys
    If CInt(Split(ele, "-")(1)) = annee And UCase(dico.Item(ele)) = UCase(TypeSol) Then
        Rech = Rech + 1
    End If
Next ele
Range("G5") = Rech

'Recherche 4==>Terre- 2014
TypeSol = "Terre"
annee = 2014
Rech = 0
For Each ele In dico.keys
    If CInt(Split(ele, "-")(1)) = annee And UCase(dico.Item(ele)) = UCase(TypeSol) Then
        Rech = Rech + 1
    End If
Next ele
Range("H5") = Rech

End Sub
 

Discussions similaires

Réponses
3
Affichages
246
Réponses
10
Affichages
497
Les cookies sont requis pour utiliser ce site. Vous devez les accepter pour continuer à utiliser le site. En savoir plus…