Hello There,
I have a sub which check if the value entered is Numeric. I am passing the cell's range as a parameter. Could you please advise and correct
It errors out in Function IsValueNumeric
Rumtime error '1004':
Method 'Range'of object _Global failed
The code:
Thanks & regards,
Don
I have a sub which check if the value entered is Numeric. I am passing the cell's range as a parameter. Could you please advise and correct
It errors out in Function IsValueNumeric
Rumtime error '1004':
Method 'Range'of object _Global failed
Code:
Range(pRange).Interior.ColorIndex = 0
and
Range(pRange).Interior.ColorIndex = 6 'Highlight with Yellow Color
The code:
Code:
Sub DataValidate()
Dim Output As Boolean
If Not IsValueNumeric(Range("FIsNumeric")) Then
MsgBox ("Value is not Numeric")
End If
End Sub
Code:
Public Function IsValueNumeric(pRange As Range) As Boolean
If IsEmpty(pRange.Value) Or _
Len(pRange.Value) <> 7 Or _
IsNumeric(pRange.Value) <> True Then
GoTo Exception_IsValueNumeric
End If
Done:
IsValueNumeric = True
Range(pRange).Interior.ColorIndex = 0
Exit Function
Exception_IsValueNumeric:
Range(pRange).Interior.ColorIndex = 6 'Highlight with Yellow Color
MsgBox "- Employee Number has to be Numeric, not empty and of Length 7"
IsValueNumeric = False
End Function
Thanks & regards,
Don