Dim sh As Worksheet
Dim sFormula As String
Dim sFormula2 As String
Dim DernierID As Integer
Dim lignevide As Integer
Sub Copier_Coller(CopyRange As String)
With Worksheets("Facture").Range("A1")
If .Value Like "*CFA*" Then
Set sh = Sheets("CFA")
ElseIf .Value Like "*UREA*" Then
Set sh = Sheets("UREA")
Else
Set sh = Sheets("UFI")
End If
End With
DernierID = WorksheetFunction.Max(sh.Range("A:A"))
lignevide = sh.Range("A" & Rows.Count).End(xlUp).Row + 1
If lignevide < 2 Then lignevide = 2
sh.Cells(lignevide, 1) = DernierID + 1
sh.Range("B" & lignevide).Resize(, Range(CopyRange).Count) = Application.Transpose(Range(CopyRange))
sFormula = "=SIERREUR(SOMME($J$" & lignevide & ":$K$" & lignevide & ");""Attention ! il y a une erreur !"")"
sFormula2 = "=SIERREUR(SOMME($m$" & lignevide & "*$n$" & lignevide & ");""Attention ! il y a une erreur !"")"
sh.Cells(lignevide, "L").FormulaLocal = sFormula
sh.Cells(lignevide, "o").FormulaLocal = sFormula2
End Sub