Also, other than data validation in Excel, do you know of a good code to prevent duplication? Therefore, if someone tries to add the same employee id number more than once, they will get an error message that tells them this is a duplicate employee id number, please enter a different number. I have many different codes I presently experimenting with for this to work successfully. This question is the least of my worries. Again I really do appreciate any help you can give.
I got that from your email (I don't have access to my email while at work, so I had to wait until I got home). One way to do this would be to use a worksheet_change event. Go to the VB editor, press control-r for the project window, double click on the Sheet2 icon (or whatever you have for your second sheet) within the workbook you want this to occur. In the code pane, paste the following:
Private Sub Worksheet_Change(ByVal Target As Range)
Dim chgdCell As Range
For Each chgdCell In Target.Cells
If chgdCell.Column = 2 Then
If Application.WorksheetFunction.CountIf(Intersect(Columns(2), _
Target.Worksheet.UsedRange), chgdCell) > 1 Then
MsgBox "This is a duplicate id number, please enter a different number"
chgdCell.Select
End If
End If
Next chgdCell
End Sub
See if that suits your needs, and as always let us know any more ways we can help!
Welcome to vbaexpress