Re : SYNTAXE COLLER VALEUR Apres formule
Bonjour Robert, et merci de votre proposition.
Je viens d'ajouter d'autres formules comme ci dessous. Mais je ne comprends pas ou justement sont insérer les formules dans la méthode sans formule que vous proposé? je vous joins un fichier exemple.
Private Sub Worksheet_Change(ByVal Target As Range)
Dim fdesign
Dim funit
Dim fpu
Dim fmontant
fdesign = "=IF(RC[-1]<>"""",VLOOKUP(RC[-1],PRODUIT!R1C[-1]:R65536C[7],2,0),"""")"
funit = "=IF(RC[-7]<>"""",VLOOKUP(RC[-7],PRODUIT!C[-7]:C[-5],3,0),"""")"
fpu = "=IFERROR(IF(RC[-9]="""",IF(RC[2]="""","""",RC[2]),IF(RC[2]="""",RC[45],RC[2])),"""")"
fmontant = "=IFERROR(IF(RC[-2]<>"""",IF(RC[2]="""",SUM(RC[-2]*RC[-1]),""""),""""),"""")"
'si ajout reference
If Target.Count > 1 Then Exit Sub
If Target.Column = 1 Then
Application.DisplayAlerts = False
Application.EnableEvents = False
Target.Offset(0, 1) = fdesign
Target.Offset(0, 7) = funit
Target.Offset(0, 9) = fpu
Target.Offset(0, 10) = fmontant
Target.Offset(0, 1) = Target.Offset(0, 1).Value
Target.Offset(0, 7) = Target.Offset(0, 7).Value
Target.Offset(0, 9) = Target.Offset(0, 9).Value
Target.Offset(0, 10) = Target.Offset(0, 10).Value
Application.EnableEvents = True
End If
'si ajout quantité
If Target.Count > 1 Then Exit Sub
If Target.Column = 9 Then
Application.EnableEvents = False
Target.Offset(0, 2) = fmontant
Target.Offset(0, 2) = Target.Offset(0, 2).Value
Application.EnableEvents = True
End If
'si ajout prix unitaire
If Target.Count > 1 Then Exit Sub
If Target.Column = 10 Then
Application.EnableEvents = False
Target.Offset(0, 1) = fmontant
Target.Offset(0, 1) = Target.Offset(0, 1).Value
Application.DisplayAlerts = True
Application.EnableEvents = True
End If
End Sub