I have two dynamic ranges "kro_Sg" and kro_Data". I am referencing these in the kro function, which uses them to call the BestFitEasy function. The BestFitEasy function then uses the local version of these ranges ("RangeX" and "RangeY") and the LINEST command to find the R2 value of the ranges. It is able to find a value, but the problem is that the value is not the same compared to LINEST using "Kro_Sg" and "kro_Data". The code is below.
As you can see, poly3_r2 and poly32_r2 should be the same, but they are different values. poly3_r2 = 0.996 and poly32_r2 = 1.0. This is the entirety of the code, so the values should not be changing.
I also don't know how to display any of these ranges in the intermediate window. That might help with the debugging process.
Code:
Function kro(sg) As Double
Application.Volatile
kro = BestFitEasy(sg, Sheet2.Range("kro_Sg"), Sheet2.Range("kro_Data"))
End Function
Function BestFitEasy(input_value, RangeX As Range, RangeY As Range) As Double
poly3_r2 = Evaluate("INDEX(LINEST(RangeY,RangeX^{1,2,3},,1),3,1)")
poly32_r2 = Evaluate("INDEX(LINEST(kro_Data,kro_Sg^{1,2,3},,1),3,1)")
End Function
As you can see, poly3_r2 and poly32_r2 should be the same, but they are different values. poly3_r2 = 0.996 and poly32_r2 = 1.0. This is the entirety of the code, so the values should not be changing.
I also don't know how to display any of these ranges in the intermediate window. That might help with the debugging process.