Thread: Validation
View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GJones GJones is offline
external usenet poster
 
Posts: 132
Default Validation

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






-----Original Message-----
I need to validate what the user inputs in a specific

cell. I have set
validation on that cell for Whole numbers to avoid having

the user type
letters and it works fine but when I run the macro that

promts the user
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 time


---
Message posted from http://www.ExcelForum.com/

.