Hi,
I could use some help in determining why my TREND formula in Vba brings a differnt result than the EXCEL trend formula. I use the same parameters:
(y,x, new x)
I use a High and Low threshold value to compare to the Payouts at those threshold levels:
Arg1(1) Arg2(1)
Arg1(2) Arg2(2)
UpAch/LowAch UpPay/LowPay
218,090,462.00 12,974.99
174,472,369.60 3,243.75
Performance 194,558,975.00
Performance % 89.2%
Actual Payout 7,725
Excel returns $7,725
Access Returns $8,451.80 (which i can recreate this amount if I added another row of variables to excel @ 0).
Here is my VBA Trend Function:
Function NewTrend(Payout1 As Double, Payout2 As Double, Achieve1 As Double, Achieve2 As Double, performance As Double) As Double
On Error GoTo Err_Trend
Dim objExcel As Excel.Application
Dim Arg1(2) As Double
Dim Arg2(2) As Double
Dim X As Integer
Dim result As Variant
Arg1(1) = Payout1
Arg1(2) = Payout2
Arg2(1) = Achieve1
Arg2(2) = Achieve2
Set objExcel = CreateObject("Excel.Application")
result = objExcel.WorksheetFunction.Trend(Arg1, Arg2, performance)
objExcel.Quit
Set objExcel = Nothing
NewTrend = result(1)
Exit_Trend:
Exit Function
Err_Trend:
MsgBox Err.Number & " " & Err.Description
Resume Exit_Trend
End Function
Any insight would be appreciated.
Thanks
I could use some help in determining why my TREND formula in Vba brings a differnt result than the EXCEL trend formula. I use the same parameters:
(y,x, new x)
I use a High and Low threshold value to compare to the Payouts at those threshold levels:
Arg1(1) Arg2(1)
Arg1(2) Arg2(2)
UpAch/LowAch UpPay/LowPay
218,090,462.00 12,974.99
174,472,369.60 3,243.75
Performance 194,558,975.00
Performance % 89.2%
Actual Payout 7,725
Excel returns $7,725
Access Returns $8,451.80 (which i can recreate this amount if I added another row of variables to excel @ 0).
Here is my VBA Trend Function:
Function NewTrend(Payout1 As Double, Payout2 As Double, Achieve1 As Double, Achieve2 As Double, performance As Double) As Double
On Error GoTo Err_Trend
Dim objExcel As Excel.Application
Dim Arg1(2) As Double
Dim Arg2(2) As Double
Dim X As Integer
Dim result As Variant
Arg1(1) = Payout1
Arg1(2) = Payout2
Arg2(1) = Achieve1
Arg2(2) = Achieve2
Set objExcel = CreateObject("Excel.Application")
result = objExcel.WorksheetFunction.Trend(Arg1, Arg2, performance)
objExcel.Quit
Set objExcel = Nothing
NewTrend = result(1)
Exit_Trend:
Exit Function
Err_Trend:
MsgBox Err.Number & " " & Err.Description
Resume Exit_Trend
End Function
Any insight would be appreciated.
Thanks