View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Mike H Mike H is offline
external usenet poster
 
Posts: 11,501
Default Macro for checking duplicate entries

ken,

Try this. Right click the sheet tab, view code and paste this in:-

Private Sub Worksheet_Change(ByVal Target As Range)
Dim myRange As Range
If Not Intersect(Target, Range("E2:E1000")) Is Nothing Then ' for a range
If IsNumeric(Target) Then
lastrow = Cells(Cells.Rows.Count, "e").End(xlUp).Row
Set myRange = Range("E2:E" & lastrow - 1)
For Each c In myRange
If c.Value = Target.Value Then
Address = c.Address
MsgBox "Already entered in " & Address
Exit Sub
End If
Next
End If
End If
End Sub

Mike

"Ken" wrote:

Hey, Group!
Another post by a macro noob (trying hard to learn something)....I
have a spreadsheet that has a column for entering a unique ID number
(6 digits) Column E, and I need to know that I have entered a
previously entered ID, with a warning, and "Do you wish to
continue?"....with the warning telling me the line # of the previously
entered ID....as I have it right now I have a just a formula that will
flag the new cell and turn it a different color, with no reference to
the previously entered ID, which is ok, but lacking....I really need a
macro, and I have no idea where to start, although I can maneuver
around the VBA somewhat....I'm really struggling on this one...does
anyone have something similar that I might be able to use? Any help
will be greatly appreciated.
Thanks in advance!!!
Ken