K
Karen53
Hi,
I've been trying to validate the value of a textbox with partial success.
The value input must be a number but it can also be a decimal number. I am
trying to catch alpha characters but my Like statement is not catching it. I
have tried various versions, "A-Z", "a' - "z", a-z.
Sub EditAllowedVariance(PasswordGood)
Dim NuAllowance As String
If PasswordGood = True Then
NuAllowance = InputBox("Enter desired allowed variance", _
"Enter Variance")
If NuAllowance Like ["a-z"] Then
MsgBox "Variance must be a number"
Goto InvalidNo
End If
If Val(NuAllowance) < 0 Then
MsgBox "Allowance must be positive number"
GoTo InvalidNo
Else
GrossUppg.Range("I2").NumberFormat = "00.00"
GrossUppg.Range("I2").Value = Val(NuAllowance)
End If
End If
InvalidNo:
End Sub
I've been trying to validate the value of a textbox with partial success.
The value input must be a number but it can also be a decimal number. I am
trying to catch alpha characters but my Like statement is not catching it. I
have tried various versions, "A-Z", "a' - "z", a-z.
Sub EditAllowedVariance(PasswordGood)
Dim NuAllowance As String
If PasswordGood = True Then
NuAllowance = InputBox("Enter desired allowed variance", _
"Enter Variance")
If NuAllowance Like ["a-z"] Then
MsgBox "Variance must be a number"
Goto InvalidNo
End If
If Val(NuAllowance) < 0 Then
MsgBox "Allowance must be positive number"
GoTo InvalidNo
Else
GrossUppg.Range("I2").NumberFormat = "00.00"
GrossUppg.Range("I2").Value = Val(NuAllowance)
End If
End If
InvalidNo:
End Sub