Hello all,
I am currently using this macro to prevent users from entering similar entries within a spreadsheet.
However, the problem I am facing is that its effect is for the whole spreadsheet. How can I limit this macro to one column only (say column B)?
Thanks for the help!
I am currently using this macro to prevent users from entering similar entries within a spreadsheet.
Code:
Private Sub Worksheet_Change(ByVal Target As Excel.Range)
' Vasant Nanavati 2002
On Error GoTo ErrorHandler
If Not Intersect(Target, Columns(1)) Is Nothing Then
If Not Range(Cells(1, 1), Cells(Intersect _
(Target, Columns(1)).Row - 1, 1)).Find _
(Target.Value, LookIn:=xlValues, LookAt:= _
xlWhole) Is Nothing Then
MsgBox "Part no. already exists!"
Application.EnableEvents = False
With Intersect(Target, Columns(1))
.ClearContents
.Select
End With
End If
End If
ErrorHandler:
Application.EnableEvents = True
End Sub
However, the problem I am facing is that its effect is for the whole spreadsheet. How can I limit this macro to one column only (say column B)?
Thanks for the help!