Rebonjour,
Ci-dessus, le code du fichier. Les 2 lignes ou j'utilise des Formular1c1 plante quand je prends un parametre P1 non entier.
Merci de votre aide!
********************************************************
Private Sub CommandButton1_Click()
Dim L, Maligne, LigneTitre As Integer
Dim P1, P2, Q1, Q2, P, Q As Integer
Dim Titre, Sens, Fonds, SearchTitre, Test, NumLigne, Operation
'Recuperation des valeurs saisies
Fonds = ComboBox1.Value
Titre = ComboBox2.Value
Sens = ComboBox3.Value
Q1 = TextBox1.Value
P1 = TextBox2.Value
ComboBox1.Value = ""
ComboBox2.Value = ""
ComboBox3.Value = ""
TextBox1.Value = ""
TextBox2.Value = ""
TextBox1.SetFocus
Operation = ""
P = 0
Q = 0
Sheets(Fonds).Activate
Maligne = 2
Do Until Sheets(Fonds).Cells(Maligne + 1, "B").FormulaR1C1 = ""
Maligne = Maligne + 1
Cells(Maligne, 2).Select
If Cells(Maligne, 2).Text = Titre Then
Q2 = Cells(Maligne, 3).Value
P2 = Cells(Maligne, 4).Value
If Sens = "ACHAT" Then
Operation = "-"
Q = Q1 + Q2
Cells(Maligne, 3).Value = Q
Cells(Maligne, 4).FormulaR1C1 = "=(" & Q1 & "*" & P1 & "+" & Q2 & "*" & P2 & ")/" & Q
ElseIf Sens = "VENTE" Then
Operation = "+"
If (Q1 = Q2) Then
ActiveSheet.Rows(Maligne).EntireRow.Delete
Else
Q = Q2 - Q1
Cells(Maligne, 3).Value = Q
End If
End If
Cells(1, 1).Select
Sheets("Synthese").Select
[A3].Value = [A3].Value
[A3].FormulaR1C1 = "=" & Operation & Q1 & "*" & P1 & "+(" & [A3].FormulaR1C1 & ")"
End If
Loop
End Sub