I recently changed a sub to a function, and the function no longer works.
If I comment out the definition of RangeA and RangeB and use the new definition of Bo it works, so how should I define RangeA and RangeB?
Code:
Function Bo(p) As Double
Dim BoCoeff As Variant
' Start at bottom and looks for last filled cell
Sheet2.Range("A9", Range("A65536").End(xlUp)).Name = "RangeA"
Sheet2.Range("B9", Range("B65536").End(xlUp)).Name = "RangeB"
BoCoeff = Evaluate("LinEst(RangeB, RangeA^{1,2,3})")
Bo = p ^ 3 * BoCoeff(1) + p ^ 2 * BoCoeff(2) + p ^ 1 * BoCoeff(3) + BoCoeff(4)
' Below only used in debugging
' Bo = p ^ 3 * Sheet2.Range("A3") + p ^ 2 * Sheet2.Range("B3") + p ^ 1 * Sheet2.Range("C3") + Sheet2.Range("D3")
End Function