Hello,
Private Sub Cmd_Prix_Revient_Click()
Dim i As Integer
Dim codepdt As String
Dim matierepremiere As Integer
Dim j As Integer
Dim quantite As Double
Dim prixmax As Double
Dim prixtotale As Double
Dim k As Integer
i = 2
While Sheets("Prod°Finis").Cells(i, 1).Value <> ""
codepdt = Sheets("Prod°Finis").Cells(i, 1).Value
j = 1
While Sheets("Mat1°-Prod Finis").Cells(j, 1).Value <> ""
If codepdt = Sheets("Mat1°-Prod Finis").Cells(j, 1).Value Then
matierepremiere = Sheets("Mat1°-Prod Finis").Cells(j, 2).Value
quantite = Sheets("Mat1°-Prod Finis").Cells(j, 3).Value
Sheets("Prix-Mat°Prem-Fourn").Activate
k = 1
While Sheets("Prix-Mat°Prem-Fourn").Cells(k, 1).Value <> ""
If matierepremiere = Sheets("Prix-Mat°Prem-Fourn").Cells(k, 2).Value Then
prixtotale = Round(prixtotale + Sheets("Prix-Mat°Prem-Fourn").Cells(k, 3).Value * quantite)
If Sheets("Prix-Mat°Prem-Fourn").Cells(k, 3).Value > prixmax Then
prixmax = Sheets("Prix-Mat°Prem-Fourn").Cells(k, 3).Value
End If
End If
k = k + 1
Wend
Sheets("Mat1°-Prod Finis").Activate
Sheets("Prod°Finis").Activate
End If
j = j + 1
Wend
UserForm1.Txt_Prix_Revient = UserForm1.Txt_Prix_Revient & " Prix de revient " & Range("B" & i).Value & " : " & prixtotale & "€" & Chr(10) & " Prix du composant le plus cher : " & prixmax & "€" & Chr(10) & Chr(10)
Range("E" & i).Value = prixtotale
i = i + 1
prixtotale = 0
prixmax = 0
Wend
UserForm1.Show
End Sub
R@g