duplicate entries

  • Thread starter Thread starter HR Director
  • Start date Start date
H

HR Director

I have a cloumn that you have to put in an EE number, it the useis Vkookup
to find the employee and the propigates the information requested. I need a
way to tell if I enter a duplicate number in the EE number column. any ideas
 
Yes. The following little macro will bring up a message box stating that
the entry is a duplicate. Place this macro in the sheet module of your
sheet. To access that module, right-click on the sheet tab and click on
View Code. Paste this macro into the displayed module. "X" out of the
module to return to your sheet. HTH Otto
Private Sub Worksheet_Change(ByVal Target As Range)
If Target.Count > 1 Then Exit Sub
If IsEmpty(Target.Value) Then Exit Sub
If Not Intersect(Target, Range("B:B")) Is Nothing Then
If Application.CountIf(Range("B:B"), Target.Value) > 1 Then
MsgBox "The entry is a duplicate.", 16, "Duplicate"
End If
End If
End Sub
If you want this macro to clear the duplicate entry, place this line after
the MsgBox line:
Target.ClearContents
 
Hi,

You can use Data, Validation to prevent the entry of duplicates:

You can prevent duplicate entries in a range as follows:

1. Highlight the range, lets say A1:A100
2. Choose the command Data, Validation
3. Under Allow choose Custom
4. Enter the following formula in the Formulas box:
=COUNTIF(A$1:A$100,A1)=1

One thing to keep in mind - if the user copies and pastes data into the
range where the Data Validation is, it is wiped out and anything can be
entered.

If this is helpful, please click the Yes button.

Cheers,
Shane Devenshire
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top