View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Bob Flanagan Bob Flanagan is offline
external usenet poster
 
Posts: 340
Default User Name From List

If you display a listbox containing the allowed names and require that a
name be selected before the dialog is closed, that would solve your
problems.

You can put a list of names on a worksheet and then populate the listbox
with them. The following is untested but should get you close: (and
debugging is always a learning experience!)

unload userform1
dim cell as range
set cell = sheets("where my list is").range("a1")
While not isempty(cell)
userform1.additem cell.value
set cell = cell.offset(1,0)
Wend
do
Userform1.show
if userform1.listbox1.listindex < -1 then exit do
msgbox "Please make a selecton"
Loop
msgbox "You selected list item " & userform1.listbox1.listindex+1

Robert Flanagan
Macro Systems
Delaware, U.S. 302-234-9857
http://www.add-ins.com
Productivity add-ins and downloadable books on VB macros for Excel

"novicevbaer " wrote in message
...
Hello.... I am trying to create user names so that when a user opens the
workbook and enters the user name into a sign on form their store number
and specific buying budget is entered into the beginning balance for
forecasting. I easily did that by saying

If txtUser = apple then budget = $100,000

Now, however, I am wondering what I do if a user enters something that
is not on the list at all? Is there a way to have the user form entry
compare to a list for validation?

And also, what do I do if the user entry is not validated? I was
thinking about making the form read only at that point but I'm not sure
how to do this.

Any information or direction would be greatly appreciated as to how
best to achieve this.

Thank you!


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