LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35
Default Stop duplicate record

I'm using the following code to stop duplicate records being entered
into column A. In principle the macro works great but I would like to
add some enhancements.

First, on entry I'd like a message to say which cell has a duplicate
record, if one exists.
Secondly, I'd like the cell pointer (active cell) to goto the
duplicate record if one exists.

Any help would be greatly appreciated.

Thanks
burl_h

Private Sub Worksheet_Change(ByVal Target As Range)
Dim LastRow As Integer
If Target.Column = 1 Then
If Not IsEmpty(Target.Value) Then
LastRow = Cells(65536, Target.Column).End(xlUp).Row
For i = 1 To LastRow
If i < Target.Row Then
If Cells(i, Target.Column).Value = Target.Value Then
MsgBox Target.Value & " already exists.", vbExclamation
Target.Value = Empty
Exit For
End If
End If
Next i
End If
End If
End Sub
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
On Duplicate, update record MikeD1224 Excel Discussion (Misc queries) 1 April 2nd 09 10:19 PM
How to delete duplicate record Lillian Lian Excel Programming 2 December 8th 07 12:03 AM
Duplicate Record.... sal21[_46_] Excel Programming 1 November 11th 04 08:11 AM
Duplicate Record.... sal21[_45_] Excel Programming 1 November 10th 04 04:10 PM
Duplicate Record.... sal21[_44_] Excel Programming 1 November 9th 04 04:24 PM


All times are GMT +1. The time now is 08:09 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"