Hi all,
While I'm comfortable with programming, I'm rusty and I have never seen VBA before.
I'm trying to make a macro that makes a graph with trendline based on whatever range of numbers I have selected. I guess that means that in the code below, I want to change the sheet and range references to whatever is currently selected. Your answer will be appreciated. Thanks.
Charts.Add
ActiveChart.ChartType = xlLineMarkers
ActiveChart.SetSourceData Source:=Sheets("R1 INT").Range("AC12:AC15")
ActiveChart.Location Where:=xlLocationAsObject, Name:="R1 INT"
ActiveChart.SeriesCollection(1).Select
ActiveChart.SeriesCollection(1).Trendlines.Add(Type:=xlLinear, Forward:=0, _
Backward:=0, DisplayEquation:=True, DisplayRSquared:=False).Select
ActiveChart.SeriesCollection(1).Trendlines(1).DataLabel.Select
Selection.Left = 141
Selection.Top = 1
End Sub
Bookmarks