|
End Function要放到最后。还有那些没有函数头的也删除。同一个函数搞那么多干啥?- Function getTrendLine(RngX As Range)
- Application.Volatile
- On Error Resume Next
- Dim iChart As Chart
- Set iChart = ActiveSheet.Shapes.AddChart2(240, xlXYScatter).Chart
- iChart.SetSourceData Source:=RngX
- Dim iTrendline As Trendline
- Set iTrendline = iChart.FullSeriesCollection(1).Trendlines.Add
- Dim TrendLineType, TrendLineEqu, TrendLineRS, TrendLineStr
- With iTrendline
- .Type = xlPolynomial
- .Order = 3
- .DisplayRSquared = True
- .DisplayEquation = True
- .DataLabel.Select
- TrendLineStr = Selection.Text
- TrendLineEqu = Split(TrendLineStr, " ")(0)
- TrendLineRS = Split(TrendLineStr, " ")(1)
- .DisplayRSquared = False
- .DisplayEquation = False
- End With
- iChart.Parent.Delete
- getTrendLine = TrendLineEqu
- End Function
复制代码 |
|