Compter éléments de BD - code à ajuster
Bonjour chers experts d'Excel-Pratique
Je tente d'ajuster un code que vous m'aviez fourni, mais je n'y parviens pas!
Le code compte les lignes "Autres" pour chaque arrondissement dans la feuille livraison, et je souhaites ajouter un autre produit matriciel "Intérieure". Comment ajouter cette distinction.
Merci d'avance pour votre aide.
Voici la portion du code en question:
For Lig = 5 To DerLig
Référence = Range("A" & Lig)
' Si la référence est différente de total et que le nombre de ligne à passer est = 0
If InStr(1, Référence, "Total", vbTextCompare) = 0 And IncLig = 0 Then
' N'est pas la ligne "Autres"
If InStr(1, Référence, "Autres", vbTextCompare) = 0 Then
Range("B" & Lig) = Application.WorksheetFunction.SumIf(ShtS.Range("B:B"), Référence, ShtS.Range("D:D"))
Range("C" & Lig) = Application.WorksheetFunction.SumIf(ShtS.Range("B:B"), Référence, ShtS.Range("E:E"))
Else
' Ligne "Autres" = produit matriciel
Range("B" & Lig).FormulaLocal = "=SOMMEPROD((Arrondissements=""" & sArr & """)*(Installations=""Autres"")*Livré)"
Range("B" & Lig).Value = Range("B" & Lig).Value
Range("C" & Lig).FormulaLocal = "=SOMMEPROD((Arrondissements=""" & sArr & """)*(Installations=""Autres"")*Retour)"
Range("C" & Lig).Value = Range("C" & Lig).Value
End If
Else
IncLig = IncLig + 1
' Si 3ème ligne à partir de celle de Total = Arrondissement, le récupérer
If IncLig = 3 Then sArr = Range("A" & Lig)
' Si 4ème ligne, la prochaine est la bonne
If IncLig = 4 Then IncLig = 0
End If
Next Lig
Application.ScreenUpdating = True
Set ShtS = Nothing
End Sub
Bonsoir le forum
Merci à ceux et à celles qui ont jeté un œil sur ce poste. Le mien a fini par trouver!
A+