Okay, I have something that sort of works (Half the time!) but needs fixed
Sub ExistingDataSearch()
'if the new entry into the last cell in column B is already in Column B
'then look in the corresponding row column E for a blank cell
'if E is blank, don't allow the new entry
'if E is not blank, allow the new entry
NewEntry = ActiveCell.Value 'eventually this will be the ChangeEvent Cell
iOrigLastRow = ActiveSheet.Range("B65536").End(xlUp).Row - 1
If Application.WorksheetFunction.CountIf(Range("B:B"), NewEntry) > 1 Then
For r = 2 To iOrigLastRow 'will iOrigLastRow To 2 Step -1 work to search from the bottom up?
Set found = Range(Cells(2, 2), Cells(iOrigLastRow, 2)).Find(NewEntry, LookIn:=xlValues)
' If Not found Is Nothing Then
firstaddress = found.Address
Do
If found.Row <> r Then
If IsEmpty(found.Offset(0, 3)) Then
MsgBox ("you cannot enter data")
Exit Sub 'AND DON'T allow entry into cell
End If
End If
Set found = Range(Cells(2, 2), Cells(iOrigLastRow, 2)).FindNext(found)
Loop While found.Address <> firstaddress
' Loop While Not found Is Nothing And found.Address <> firstAddress
' End If
Next
End If
End Sub
It finds them, checks column E and messages & Exits Sub if the blank is found - WORKS GREAT *** but now I need to make it disallow the entry
If a corresponding blank cell is never found it Loops CONTINUOUSLY
-it doesn't seem to ever think the found.Address = firstaddress
I have no idea what I'm doing, so feel free to majorly critique this mess!
Once I get it working, I stilll need to make it into a Change Event, it doesn't have to happen every time a cell in Column B is changed just when the newest entry, which will be in the last row (first open) is entered.
Bookmarks