Bonjour à tous,
Je rencontre un problème avecun script vba excel.
Voici le script:
'nombre de réparation
Ref = Range("K3").Value
Set Plge1 = Sheets("Tableau Cumulatif").Range("J7:J" & Range("J7").End(xlDown).Row)
Set Plge2 = Sheets("Tableau Cumulatif").Range("N7:N" & Range("N7").End(xlDown).Row)
For Each cel In Sheets("COUT PAR PÉRIODE").Range("A5:A" & Range("A5").End(xlDown).Row)
If cel.Value <> "" Then
cel.Offset(0, 10) = Application.WorksheetFunction.CountIf(Plge1, cel & Ref)
cel.Offset(0, 11) = Application.WorksheetFunction.SumIf(Plge1, cel & Ref, Plge2)
End If
Next
'Total argent
nbLignes = Cells(Rows.Count, "A").End(xlUp).Row
Set Plage = Sheets("COUT PAR PÉRIODE").Range("L5:L" & nbLignes)
For Each CELL In Plage
Range("L1") = Application.WorksheetFunction.Sum(Plage)
Next
'% SELON TYPE
On Error Resume Next
nbLignes = Cells(Rows.Count, "A").End(xlUp).Row
Set Plage = Sheets("COUT PAR PÉRIODE").Range("K5:K" & nbLignes)
For Each CELL In Plage
CELL.Offset(0, 2).Value = CELL.Value / Application.WorksheetFunction.Sum(Plage)
Next CELL
'% SELON Montant
nbLignes = Cells(Rows.Count, "A").End(xlUp).Row
Set Plage = Sheets("COUT PAR PÉRIODE").Range("L5:L" & nbLignes)
For Each CELL In Plage
CELL.Offset(0, 2).Value = CELL.Value / Application.WorksheetFunction.Sum(Plage)
Next CELL
MsgBox "Terminé"
End Sub
Mon problème est que quand il va chercher le nombre de fois ou apparait un nom dans la feuille "COUT PAR PÉRIODE", il me donne un nombre de 34 fois quand pourtant il y en à 680 dans la colone J. J'ai l'impression qu'il vois que les 43 première lignes.
Pouvez-vous m'aider svp?
Merci de votre aide.