Sub AjoutModuleEtCode()
Dim Code As String
Dim LigneSuiv As Long
Code = "Function EcartEnergie(Energie as single, D as single, e as single) " & vbCrLf
Code = Code & " EcartEnergie=" & Replace(Range("B2").Value, ",", ".") & vbCrLf
Code = Code & "End Function"
With ThisWorkbook.VBProject.VBComponents("ModFonction").CodeModule
.DeleteLines 1, .CountOfLines
LigneSuiv = .CountOfLines + 1
.InsertLines LigneSuiv, Code
End With
End Sub