RATE formula working in Excel spreadsheet but not VBA

rforster10

New Member
Joined
Mar 11, 2022
Messages
2
Hello Everyone,

When I use the RATE formula in my Excel spreadsheet it works:
=RATE(360,3419.64612201533,-425000,75377.9008606371)

The formula gives me 0.760897490282994% which is correct for my purposes.

However, when I try to code the Rate function using VBA in my macro, I get a runtime '5' error. See below for code.

VBA Code:
Sub LoanCalculator()
        Dim periods As Double
        Dim payment As Double
        Dim principal As Double
        Dim futureValue As Variant
        Dim interestRate As Double
        periods = 360
        payment = 3419.64612201533
        principal = -425000
        futureValue = 75377.9008606371
        interestRate = Rate(periods, payment, principal, futureValue)
        Debug.Print(interestRate)
    End Sub

I need to use a principal amount that is negative in VBA for my purposes. Can someone please help me?

Thanks!
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi and welcome to MrExcel!

Change this:
interestRate = Rate(periods, payment, principal, futureValue)

For this:
interestRate = WorksheetFunction.Rate(periods, payment, principal, futureValue)
 
Upvote 0
Solution
Hi and welcome to MrExcel!

Change this:
interestRate = Rate(periods, payment, principal, futureValue)

For this:
interestRate = WorksheetFunction.Rate(periods, payment, principal, futureValue)
Thanks, Dante. This solved my issue. I really appreciate you taking the time to show me this.
 
Upvote 0
Im glad to help you, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,064
Messages
6,122,936
Members
449,094
Latest member
teemeren

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