Bonjour,
J'ai deux listes dans deux onglets différents. Dans ma 1er liste des objets sont répétées plusieurs fois (colonne H) avec des prix différents (colonne AB).
Dans ma 2iem liste je veux calculer la moyenne pour chaque objet en faisant une recherche dans ma 2iem liste.
J'utilise la fonction Average mais ça bloque quelque part car il me recopie juste le 1er prix trouvé pour une personne.
Sub Moyenne()
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Dim trouve As Boolean
Dim wkIndic3, j, feuil As Integer
Dim i As Long
Dim wIndiq, wImprt As Worksheet
Set wIndiq = ActiveWorkbook.Worksheets("Indica3")
With wIndiq
'wkIndic3 = .Range("B65536").End(xlUp).Row
wkIndic3 = .Range("B" & .Rows.Count).End(xlUp).Row
j = 5
For i = 5 To wkIndic3
Set wImprt = ActiveWorkbook.Worksheets("Import")
trouve = False
If Trim(wImprt.Range("H" & j)) = Trim(.Range("B" & i)) Then
trouve = True
j = i
Else
For j = 5 To wImprt.Range("B65536").End(xlUp).Row
If Trim(wImprt.Range("H" & j).Value) = Trim(.Range("B" & i)) Then
trouve = True
Exit For
End If
Next j
End If
If trouve Then
.Range("C" & i).Value = Application.Average(wImprt.Range("AB" & i))
End If
Next i
End With
Application.ScreenUpdating = True
Application.Calculation = xlCalculationAutomatic
End Sub
Merci d'avance