Sub MatchUserInput()
Dim strSearchTerm
Dim FirstMatch As Range
Dim FirstAddress
strSearchTerm = InputBox("Please enter the invitation number to find", "Warsaw 2014")
If strSearchTerm <> "" Then
Set FirstMatch = ActiveSheet.Cells.Find(strSearchTerm, LookAt:=xlWhole)
If FirstMatch Is Nothing Then
MsgBox "That invitation could not be found"
Else
FirstAddress = FirstMatch.Address
While Not FirstMatch Is Nothing
If FirstMatch = FirstMatch Then
If FirstMatch.Interior.Color = vbYellow Then
FirstMatch.Interior.Color = vbRed
MsgBox "Invitation already used!"
Exit Sub
End If
End If
FirstMatch.Interior.Color = vbYellow
Set FirstMatch = ActiveSheet.Cells.FindNext(FirstMatch)
If FirstMatch.Address = FirstAddress Then
Set FirstMatch = Nothing
End If
Wend
End If
End If
End Sub
Bookmarks