How to get isnumeric function to display an "error" message when necessary.
Sub DetermineinterestSelectCase()
Dim loan As Variant
Dim interest As Double
loan = InputBox("Enter your desired loan amount, from 1 dollar to 5 million dollars.")
Select Case loan
Case IsNumeric(loan) = False: MsgBox ("Error")
Case Is < 1000000: interest = ".08"
Case 1000000 To 4000000: interest = ".10"
Case Is > 4000000: interest = ".11"
End Select
MsgBox ("The loan amount was " & loan & " with an interest rate of " & interest & "")
End Sub
Sub DetermineinterestIf()
Dim loan As Variant
Dim interest As Double
loan = InputBox("Enter your desired loan amount, from 1 dollar to 5 million dollars.")
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
2 answers
It's up to you to handle each case.
If IsNumeric(s) then
MsgBox(msg)
else
do other stuff
end if
If Not IsNumeric(s) Then
...
to handle the error case.