Function PolyEq(ByVal MatX As Range, ByVal MatY As Range, Optional ByVal R As Variant = 3) As String

'Calcul puis écriture de l'équation polynomiale définie
'par les points contenus dans MatX et MatY
'Identique à Poly_calcul mais renvoi uniquement la formule
'r=arrondi des coefficients
'!attention! trop peu de décimale efface le coefficient

'Traitement de l'arrondi
R = CLng(R)

'Tailles matrices
Dim l As Long, L2 As Long, C As Long, C2 As Long
l = MatX.Rows.Count
L2 = MatY.Rows.Count
C = MatX.Columns.Count
C2 = MatY.Columns.Count
'Erreur de taille
If C > 1 Or C2 > 1 Then PolyEq = "#COLONNE!": Exit Function
If l <> L2 Then PolyEq = "#LIGNE!": Exit Function

Dim I As Long, P As Double

For I = 1 To l
    P = WorksheetFunction.Round(Poly(MatX, MatY, I), R)
    If P > 0 Then PolyEq = PolyEq & " +"
    If P <> 0 Then
    Select Case P
            Case Is <> 1
                Select Case I
                Case Is < l - 1
                PolyEq = PolyEq & " " & P & "*X^" & (l - I)
                Case l - 1
                PolyEq = PolyEq & " " & P & "*X"
                Case l
                PolyEq = PolyEq & " " & P
                End Select
            Case Else
                Select Case I
                Case Is < l - 1
                PolyEq = PolyEq & " " & "X^" & (l - I)
                Case l - 1
                PolyEq = PolyEq & " " & "X"
                Case l
                PolyEq = PolyEq & " " & P
                End Select
    End Select
    End If
Next I
  
End Function