#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default validation

I am trying to validate user input against data that is in the fourth column
of a worksheet named "data". The amount of rows in this sheet will vary

This is how I receive the input from the user:

Cliname = InputBox(Prompt:="Enter Client Name", Title:="Client Name")

How do I do this?

Thanks in advance.

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,163
Default validation

My first suggestion when input must come from a fixed list would be to use a
listbox or combobox for the user to select, rather than type, the values - it
eliminates the chance of mismatches based on typos, etc and is much easier
and less frustrating for the user, plus you would not need to worry about
validation since you know the answer must be in the list.

Having said that, if you still want to use typed input and validate it, you
can use the Find method to see if the input value is in the column:

Dim Found as Boolean, Cancelled as Boolean

Found = False
Cancelled = False
While (Not Found) And (Not Cancelled)
Cliname = InputBox(Prompt:="Enter Client Name", Title:="Client Name")
Cancelled = (Cliname = False)
Found = Not(Sheets("data").Range("D:D").Find(Cliname) Is Nothing)
If (Not Found) And (Not Cancelled) Then MsgBox "Invalid Client Name; retry"
WEnd

HTH

"lewscannon" wrote:

I am trying to validate user input against data that is in the fourth column
of a worksheet named "data". The amount of rows in this sheet will vary

This is how I receive the input from the user:

Cliname = InputBox(Prompt:="Enter Client Name", Title:="Client Name")

How do I do this?

Thanks in advance.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default validation

The easiest way is to use DataValidation in the cell.

otherwise you could do something like this:

Dim y As Integer

On Error Resume Next
y = WorksheetFunction.Match(Cliname, Sheets("data").Range("D:D"), 0)
On Error GoTo 0
If y 0 Then
MsgBox " match"
Else: MsgBox "no match"
End If


--
steveB

Remove "AYN" from email to respond
"lewscannon" wrote in message
...
I am trying to validate user input against data that is in the fourth
column
of a worksheet named "data". The amount of rows in this sheet will vary

This is how I receive the input from the user:

Cliname = InputBox(Prompt:="Enter Client Name", Title:="Client Name")

How do I do this?

Thanks in advance.



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default validation

A simple match can do this:

If WorksheetFunction.Match(Cliname,Sheets("Data").Ran ge("D:D"),0) = "#N/A"
--
steveB

Remove "AYN" from email to respond
"lewscannon" wrote in message
...
I am trying to validate user input against data that is in the fourth
column
of a worksheet named "data". The amount of rows in this sheet will vary

This is how I receive the input from the user:

Cliname = InputBox(Prompt:="Enter Client Name", Title:="Client Name")

How do I do this?

Thanks in advance.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default validation

How would I be able to create a listbox based upon the contents of that
column? The worksheet could contain as many as 30,000 rows, though there
would probably not be more than 5 different selections. Also, the data for
the entire sheet will change periodically, depending on what is copied and
pasted into it (though the column containing the listbox items would remain
in the same place (Column D).

Thanks.

"K Dales" wrote:

My first suggestion when input must come from a fixed list would be to use a
listbox or combobox for the user to select, rather than type, the values - it
eliminates the chance of mismatches based on typos, etc and is much easier
and less frustrating for the user, plus you would not need to worry about
validation since you know the answer must be in the list.

Having said that, if you still want to use typed input and validate it, you
can use the Find method to see if the input value is in the column:

Dim Found as Boolean, Cancelled as Boolean

Found = False
Cancelled = False
While (Not Found) And (Not Cancelled)
Cliname = InputBox(Prompt:="Enter Client Name", Title:="Client Name")
Cancelled = (Cliname = False)
Found = Not(Sheets("data").Range("D:D").Find(Cliname) Is Nothing)
If (Not Found) And (Not Cancelled) Then MsgBox "Invalid Client Name; retry"
WEnd

HTH

"lewscannon" wrote:

I am trying to validate user input against data that is in the fourth column
of a worksheet named "data". The amount of rows in this sheet will vary

This is how I receive the input from the user:

Cliname = InputBox(Prompt:="Enter Client Name", Title:="Client Name")

How do I do this?

Thanks in advance.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default validation

Whether you use a listbox, or combobox
Set ListFillRange $A:$A
You can set the properties to only accept a match and the
list will scroll to the closest match

Used DataValidation
Set to List
Source =$A:$A
You can set this to not accept an entry unless it is in the list.

You can do all of these with or without code.

--
steveB

Remove "AYN" from email to respond
"lewscannon" wrote in message
...
How would I be able to create a listbox based upon the contents of that
column? The worksheet could contain as many as 30,000 rows, though there
would probably not be more than 5 different selections. Also, the data for
the entire sheet will change periodically, depending on what is copied
and
pasted into it (though the column containing the listbox items would
remain
in the same place (Column D).

Thanks.

"K Dales" wrote:

My first suggestion when input must come from a fixed list would be to
use a
listbox or combobox for the user to select, rather than type, the
values - it
eliminates the chance of mismatches based on typos, etc and is much
easier
and less frustrating for the user, plus you would not need to worry about
validation since you know the answer must be in the list.

Having said that, if you still want to use typed input and validate it,
you
can use the Find method to see if the input value is in the column:

Dim Found as Boolean, Cancelled as Boolean

Found = False
Cancelled = False
While (Not Found) And (Not Cancelled)
Cliname = InputBox(Prompt:="Enter Client Name", Title:="Client Name")
Cancelled = (Cliname = False)
Found = Not(Sheets("data").Range("D:D").Find(Cliname) Is Nothing)
If (Not Found) And (Not Cancelled) Then MsgBox "Invalid Client Name;
retry"
WEnd

HTH

"lewscannon" wrote:

I am trying to validate user input against data that is in the fourth
column
of a worksheet named "data". The amount of rows in this sheet will vary

This is how I receive the input from the user:

Cliname = InputBox(Prompt:="Enter Client Name", Title:="Client Name")

How do I do this?

Thanks in advance.



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validation Data using Validation Table cell range..... Dermot Excel Discussion (Misc queries) 16 January 5th 10 09:35 PM
Data validation with validation lists and combo boxs Keith Excel Discussion (Misc queries) 1 October 12th 06 11:08 AM
Validation (Drop down list vs simple text length validation) Bob Phillips[_6_] Excel Programming 2 April 27th 04 07:47 PM
Validation (Drop down list vs simple text length validation) Jason Morin[_2_] Excel Programming 1 April 27th 04 04:56 PM
Validation (Drop down list vs simple text length validation) Pete McCosh Excel Programming 0 April 27th 04 03:49 PM


All times are GMT +1. The time now is 05:39 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"