Hello, I have a userform that I enter work order numbers in and seem to have a little problem on how to exactly set this up for how I need it to work. This is probably simple for an experienced person but I am just learning. Basically what I have is 1 textbox for the work order like: "A12345". The info is finished and submitted to my worksheet. I have this working for finding exact matches. What happens many times is I need to add a work order number to the same row, so tomorrow the user might update from the form and search the current "A12345" and then want to add "A12346". So now cell A1 looks like this: A12345 A12346 The problem with my code now is there is no way to not allow a duplicate to be created for A12345 now that the string has changed. How can I prevent this? If I use the "LookAt:=xlWhole" .... the form will not find A12345
I hope explained this correctly. Here are the pieces of code for this. Thanks for your time and help!
![]()
Private Sub cmbAdd_Click() 'Find duplicate A Number Dim strFind As String, rLookRnge As Range strFind = TextBox1 'Change to suit Set rLookRnge = Sheets(1).Columns(1) If Application.WorksheetFunction.CountIf(rLookRnge, strFind) <> 0 Then MsgBox strFind & " already exists. Please create a new A Number!", vbCritical Private Sub cmbFind_Click() Dim strFind As String 'what to find Dim FirstAddress As String Dim rSearch As Range 'range to search Set rSearch = Sheet1.Range("a6", Range("a65536").End(xlUp)) Dim f As Integer With rSearch Set c = .Find(strFind, LookIn:=xlValues) If Not c Is Nothing Then 'found it c.Select With Me 'load entry to form .TextBox1.Value = c.Offset(0, 0).Value











LinkBack URL
About LinkBacks
Register To Reply
Bookmarks