Mackeral
Board Regular
- Joined
- Mar 7, 2015
- Messages
- 232
- Office Version
- 365
- Platform
- Windows
I don't know why Isnumeric("5,4") is considered a number, but to fix it I wrote the following:
You can mess around with how you handle the error message.
VBA Code:
Function Is_Numeric(Orig_To_Test) As Boolean
' Does "To_Test" a number?
' 1/21/12 Modified. WML
' 5/9/20 Add more test conditions. WML
Prog = "Is_Numeric"
To_Test = Orig_To_Test
Knt = 0
For I = 1 To Len(To_Test)
Char = Mid(To_Test, I, 1)
If Not (IsNumeric(Char) Or Char = ".") Then
GoTo Error
End If
If Char = "." Then Knt = Knt + 1
Next I
Is_Numeric = True
If Knt < 2 Then Exit Function
Error:
IsNumeric = False
Msg1 = "The Input String is NOT a number:"
Msg2 = Quote(Orig_To_Test)
Call Msg_Err(Prog, Msg1, Msg2, False)
Stop
End Function ' Is_Number
You can mess around with how you handle the error message.