Validation

  • Thread starter Thread starter halem2
  • Start date Start date
H

halem2

I need to validate what the user inputs in a specific cell. I have se
validation on that cell for Whole numbers to avoid having the user typ
letters and it works fine but when I run the macro that promts the use
for the number, validation does not work.

How can I have the macro validate that the input is a whole number
with 5 characters and there's no letters?

thanks one more tim
 
Hi Halem2;

Use this:

Sub try()



Dim Message, Title, Default, MyValue
Message = "Enter a number that has 5 characters" ' Set
prompt.
Title = "InputBox Demo" ' Set title.
Default = "12345" ' Set default.

' Display message, title, and default value.
MyValue = InputBox(Message, Title, Default)

If Not IsNumeric(MyValue) Or Not Len(MyValue) = 5 Then
MsgBox "you can't do that"

End If





End Sub


Thanks Greg
 
Back
Top