View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
UofMoo[_2_] UofMoo[_2_] is offline
external usenet poster
 
Posts: 1
Default Checking for Duplicate entry using VBA (?!)


Hi there...
Hope this helps... I assume you want a continually running loop until
the user enters "" as the name... you'll have to check if the vbCancel
works because nowhere does it check for that response. Good Luck!
UofMoo



Msg1 = "Enter new employee name:"
EmployeeName = InputBox(Msg, vbCancel)
If EmployeeName = "" Then Exit Sub
EndIf

Do
For i = 10 To 160
If ActiveSheet.Cells(i, 4) = EmployeeName Then
Msg2 = "There is already an employee with that name..."
i = 161
Exit For
EndIf
Next
If i<161 Then Msg2 = "That was a new name."
EmployeeName = InputBox(Msg2 & " " & Msg1, vbCancel)
While EmployeeName < ""


--
UofMoo
------------------------------------------------------------------------
UofMoo's Profile: http://www.excelforum.com/member.php...o&userid=26485
View this thread: http://www.excelforum.com/showthread...hreadid=397585