IRR vba vs. worksheet function

MetLife

Active Member
Joined
Jul 2, 2012
Messages
330
Office Version
  1. 365
Hi,

I updated a macro so that it uses the IRR within vba rather than the IRR worksheet function.

To test this compared the worksheet function vs. IRR function & notice that the vba function is erroring out & the worksheet function returns a real value.

Why is this?


Worksheets("calcs").Range("BY8:BY1200").Value = Application.Transpose(arr1)

Dim t1 As Double, t2 As Double, t3 As Double
If IsError(Application.IRR(arr1, 0.01)) Then
ERCreditedRate = 0.01
Else
t1 = (1 + Application.IRR(arr1, 0.01)) ^ 12 - 1
ERCreditedRate = (1 + Application.IRR(arr1, 0.01)) ^ 12 - 1
End If


excel 2016
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Did you mean to do

Code:
arr1 = Application.Transpose(Worksheets("calcs").Range("BY8:BY1200").Value)
 
Upvote 0
No the array "arr1' is populated in the code.

The original program used the worksheet function pointing to the arr1 output. Now the vba just does the irr calculation on the array directly. Both should be the same in theory.
 
Upvote 0
No the array "arr1' is populated in the code.
Not in the code you posted.

Is it a one-dimensional array?
 
Upvote 0
Not in the code you posted.

Is it a one-dimensional array?

It is a 1-D array.

Actually I figured out this issue. The "guess" was different in VBA.

When I change this to match excel, the two match.

Thanks!
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,242
Members
452,623
Latest member
russelllowellpercy

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top