View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Rowan[_2_] Rowan[_2_] is offline
external usenet poster
 
Posts: 226
Default Check a user-input value against a list of values?

Try something like this

Sub check_id()
Dim enterID As String
Dim foundID As Range

enterID = InputBox("Enter your id")
If enterID < "" Then
With Worksheets("ID").Range("A2:A10") 'id list here
Set foundID = .Find(enterID, LookIn:=xlValues)
End With
If Not foundID Is Nothing Then
MsgBox "Rest of code or macro call here"
Else
MsgBox "ID not found"
End If
Else
MsgBox "User clicked cancel or did not enter id"
End If

End Sub

Hope this helps
Rowan

"Bill_S" wrote:

I need a basic vba routine that pops up a dialogue box so a user enters his
id. Then it checks his id against the id_list on the ID sheet that's in
workbook. If the Id is found in the list (which means it's a valid id) then
the routine executes.