Check a user-input value against a list of values?
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. |
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. |
All times are GMT +1. The time now is 09:40 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com