I often use regression in data analysis and produce relevant graph.
Here's the code:
Sub Previsioni()
'
If Range("D30") = 42 Then
MsgBox "Attenzione!!! Zona dati vuota"
End
End If
Dim Codice, Tipo, equaz
equaz = ""
Codice = Range("f5").Value
Codice = Left(Codice, 1)
If Codice = 1 Then
Tipo = xlLinear
End If
If Codice = 2 Then
Tipo = xlExponential
End If
If Codice = 3 Then
Tipo = xlLogarithmic
End If
If Codice = 4 Then
Tipo = xlPolynomial
End If
ActiveSheet.ChartObjects("Chart 31").Activate
ActiveChart.ChartArea.Select
ActiveChart.SeriesCollection(1).Trendlines.Add(Type:=Tipo, Forward:=0, _
Backward:=0, DisplayEquation:=True, DisplayRSquared:=True).Select
ActiveChart.SeriesCollection(1).Trendlines(1).DataLabel.Select
'equaz = ActiveChart.SeriesCollection(1).Trendlines(1).DataLabel
Selection.Left = 440
Selection.Top = 273
ActiveWindow.Visible = False
'Range("Equazione").Value = ActiveChart.SeriesCollection(1).Trendlines(1).DataLabel
'Selection.Paste
End Sub
As you can see I've tried to "catch" automatically in some way the formula given by the trendlines in the graph area in order to use it for other calculations, but unsuccessful.
Have you any hint on how this can be achieved?
Thanks in advance for your usual precious help.
Bookmarks