Hello,
I am trying to create a VBA function that will read in a 1-D array from Excel in order to calculate RMSE. The values in the array I am trying to read is dCOP, the difference between how an A/C unit actually performs and how it performs in a computer model. My code is as follows:
Function RMSE(ByRef dCOP() As Long) As Long
Dim n As Long
Dim Sum As Long
For n = LBound(dCOP) To UBound(dCOP)
Sum = Sum + (dCOP ^ 2)
Next n
RMSE = Application.WorksheetFunction.Sqrt(Sum)
End Function
I keep getting a #NAME? error. Any ideas on what to change?
Thanks in advance.
I am trying to create a VBA function that will read in a 1-D array from Excel in order to calculate RMSE. The values in the array I am trying to read is dCOP, the difference between how an A/C unit actually performs and how it performs in a computer model. My code is as follows:
Function RMSE(ByRef dCOP() As Long) As Long
Dim n As Long
Dim Sum As Long
For n = LBound(dCOP) To UBound(dCOP)
Sum = Sum + (dCOP ^ 2)
Next n
RMSE = Application.WorksheetFunction.Sqrt(Sum)
End Function
I keep getting a #NAME? error. Any ideas on what to change?
Thanks in advance.