Saturday

November 22, 2014

November 22, 2014

Posted by **Matt** on Friday, June 28, 2013 at 4:13pm.

Heres my code so far:

Sub DetermineinterestIf()

Dim loan As Variant

Dim interest As Double

Do

loan = InputBox("Enter your desired loan amount, from 1 dollar to 5 million dollars.")

Loop Until IsNumeric(loan)

If loan < 1000000 Then interest = ".08"

If loan > 4000000 Then interest = ".11"

If 1000000 < loan < 4000000 Then interest = ".10"

MsgBox ("The loan amount was " & loan & " with an interest rate of " & interest & ".")

End Sub

Any ideas where I have gone wrong?

- VBA Programming -
**Steve**, Friday, June 28, 2013 at 4:29pmFirst off, why use strings to specify a numeric (Double) value for interest?

I learned VBA a while ago, but I think that

If 1000000 < loan < 4000000 Then interest = .10

is invalid syntax. Try

If (1000000 < loan) and (loan < 4000000) Then interest = .10

Or, you might try

interest = 0.10

If loan < 1000000 Then interest = .08

If loan > 4000000 Then interest = .11

That is, assume the interest will be .10, and only change it if the loan amount is too big or too small

Or, if you find that you have to do other stuff depending on the interest rate, you could go whole-hog and say

If loan < 1000000 Then

interest = .08

do 8% stuff

Else If loan > 4000000 Then

interest = .11

do 11% stuff

Else

interest = .10

do 10% stuff

End If

**Answer this Question**

**Related Questions**

VBA programming - How to get isnumeric function to display an "error" message ...

math - Jefferson Bank made a loan at 6% interest for 146 days. If the amount of ...

math - Suppose that you took out a loan at 7% interest for 192 days. If the ...

n nb - The annual interest rate for a customer’s loan of $425 is 15.75%. What is...

math - The annual interest rate for a customer’s loan of $425 is 15.75%. What is...

math - The annual interest rate for a customer’s loan of $425 is 15.75%. What is...

math - The annual interest rate for a customer’s loan of $425 is 15.75%. What is...

accounting - The annual interest rate for a customer’s loan of $425 is 15.75%. ...

Accounting - The annual interest rate for a customer’s loan of $675 is 19.25%. ...

Math - The annual interest rate for a customer’s loan of $425 is 15.75%. What is...