Question : Need Excel VBA macro code to projected next number in a row of numbers using least squares best fit

Need Excel VBA macro code to projected next number in a row of numbers using least square.
Example:  
What should the next number be using least squares linear projection for this series of numbers:
743 844 1016 1148 1256 1434 1752 1840 2218 2753       3163 3270 3621 4124 ????
The number of numbers in the series could be any number of numbers so the macro code
to project the next number must suppor this.  Numbers are stored in cells A1, B1, through cell N1 in this example.

Answer : Need Excel VBA macro code to projected next number in a row of numbers using least squares best fit

My goof. I meant to use a Range variable as the input.
1:
2:
3:
4:
5:
Function ForecastValue(rgValues As Range) As Double
Dim n As Long
n = rgValues.Cells.Count
ForecastValue = Evaluate("TREND(" & rgValues.Address(external:=True) & ",," & (n + 1) & ")")(1)
End Function
Random Solutions  
 
programming4us programming4us