i have the following code:
This code only works for ChartObjects(1), but I would like it to work with the chart that I selected. I have many charts in the sheet. Many thanksCode:Sub GetTLineEq()
Dim chrtobj As ChartObject
Dim chrt As Chart
Dim srs As Series
Dim tline As trendline
Dim dlbl As DataLabel
Dim str As String
With ActiveSheet
Set chrtobj = ActiveSheet.ChartObjects(1)
Set chrt = chrtobj.Chart
Set srs = chrt.SeriesCollection(1)
Set tline = srs.Trendlines(1)
Set dlbl = tline.DataLabel
str = dlbl.Text
.Range(Selection.Address).Value = str
End With
End Sub
