Question : Excel search macro to use a bar code look for result in worksheet, start over

Hello, I use an excel worksheet download from our website to scan tickets for an event.  The tickets have bar codes printed on them.  I'll use a bar code reader to scan the ticket for the ticket id, search the worksheet to make sure the ticket id can be found and also that it hasn't already been used.  Currently doing this with the Find feature and then deleting the ticket id if it is found.  I'd like to have an easier method to do this.

So, I need help with a macro to search the worksheet for a ticket id, confirm the id exists and that it has not been used already.   If it has been used, return an audible beep and a display of "used previously", if not already used,  display "Okay", mark the next column on the same row with a Yes (for determining the first part of the macro), return to search prompt for bar code entry to do it all over again.  I'm open to anything that will accomplish the same basic concept.

 I've attached part of a sample ticket file.
 
 
Sample ticket file downlod
 

Answer : Excel search macro to use a bar code look for result in worksheet, start over

Give this a whirl.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
Sub x()
  
Dim rFind As Range, sFind, s As String

line1:
sFind = Application.InputBox("Enter bar code", , , , , , , 2)
If sFind = False Then Exit Sub

With Sheet1.Range("E2", Sheet1.Range("E2").End(xlDown))
    Set rFind = .Find(What:=sFind, LookAt:=xlWhole, MatchCase:=False, SearchFormat:=False)
    If rFind Is Nothing Then
        s = MsgBox("ID does not exist- try again?", vbYesNo)
        If s = vbNo Then Exit Sub
    Else
        If UCase(rFind.Offset(, 1)) = "YES" Then
            MsgBox "Used previously"
            Beep
        Else
            rFind.Offset(, 1) = "YES"
            MsgBox "OK"
        End If
    End If
End With

GoTo line1

End Sub
Random Solutions  
 
programming4us programming4us