Sub enregistrer_commande()
Application.ScreenUpdating = False 'on empèche les rafraichissements inutiles pendant la macro
With Sheets("DETAIL ENTREE")
'on commence par insérer une ligne en haut de tableau
.Rows("3:3").Insert Shift:=xlDown, CopyOrigin:=xlFormatFromRightOrBelow
.Range("A3").FormulaR1C1 = "=R[1]C+1" 'et on met la formule en A3
Range("E4").Copy Destination:=.Range("B3") ' on copie les infos
Range("E5").Copy Destination:=.Range("C3")
Range("E6").Copy Destination:=.Range("D3")
Range("E7").Copy Destination:=.Range("G3")
.Range("E3").FormulaR1C1 = "=VLOOKUP(RC[2],REGION!C[-2]:C,3,0)" 'on met les formules
.Range("F3").FormulaR1C1 = "=VLOOKUP(RC[1],REGION!C[-3]:C,2,0)"
Range("D12").Copy Destination:=.Range("H3") 'on copie les infos
Range("D10:D11").Copy
.Range("I3").PasteSpecial , Transpose:=True
Range("D9").Copy Destination:=.Range("K3")
Range("F12").Copy Destination:=.Range("L3")
Range("F10:F11").Copy
.Range("M3").PasteSpecial , Transpose:=True
Range("F9").Copy Destination:=.Range("O3")
'on met les formules
.Range("P3").FormulaR1C1 = "=SUM(RC[-8]+RC[-7]+RC[-6]+RC[-5]+RC[-4]+RC[-3]+RC[-2]+RC[-1])"
.Range("Q3").FormulaR1C1 = "=SUM(RC[-9]:RC[-6])/RC[-1]"
.Cells.EntireColumn.AutoFit
Application.CutCopyMode = False
End With
Application.ScreenUpdating = True
End Sub