PMT function in VBA form doesn't work with percentages in the textbox

Juliame9

New Member
Joined
Jan 10, 2018
Messages
12
Hi All,

I'm trying to build a really simple form that calculates the monthly payment of an investment.
so there are three textboxes:
1. Investment amount
2. Cost of capital
3. Amortization months.
and then I have a button that calculates the monthly payment using a PMT function.
The issue is that in the textbox of 'Cost of capital', if I put 5% for example it doesn't work! It gives me an error of 'Type mismatch'. If I put 0.05 then there's no problem and everything works.

Does anyone know how I can make it work with %? I've tried everything I could think of..

This is the code:
Payoff = Application.WorksheetFunction.Pmt(TxtCapital / 12, TxtAmort, -TxtHW)

Thanks!
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
Here we go if that doesnt work.

Code:
If InStr(TxtCapital, "%") > 0 Then
    TxtCapital = Replace(TxtCapital, "%", "") / 100
End If
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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