Validation

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
 
G

GJones

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top