Jump to duplicat entries

B

Bud

I have an application where a row is designed to allow a user to put in various product requirements for a product. Column B difines the product code. Because this must be a unique record, a product code can only be used once in the spreadsheet. I'm looking for a way to check for duplicate product codes, and if a duplicate es entered (E.g.: cell B100), Excel would jump to the existing product code (E.g.: B5) to allow further entries within the row

Any ideas

Thanks in advance for your help.
 
M

mudraker

This needs to be placed on the module sheet for the spreadsheet tha
holds your data eg sheet1 Module



Private Sub Worksheet_Change(ByVal Target As Excel.Range)
Dim TargetAddress

Dim Cell As Range
If Target.Column = "B" Then
'action only if change made in product code column
For Each Cell In Range("B1:B" & UsedRange.Count)
' check entered value against all entries in producyt code
If Cell.Address <> Target.Address Then
' do not compare target and cell address are the same
If Cell.Value = Target.Value Then
Cell.Select

Target.clear ' clears new entry form column B
or
Target.Rows.Clear ' clears new entry row
Exit For
End If
End If
Next Cell
End If
End Su
 

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

Top