LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 25
Default Duplicate Value warning

I have used the following code to give me a warning of duplicated values in a
column, at least I thought it should do this. It does in fact give me the
warning in the column BUT it give me the warning if in the same row and this
is permitted.

How do I get the code correct so it just gives me the warning for the column
values and not the row? Thanks

Private Sub Worksheet_Change(ByVal Target As Range)
'Adjust next constant to your own needs
Const myColumn As String = "B:AF"
Dim rng As Range
Dim Found As Range

Set rng = UsedRange.Columns(myColumn)
If Intersect(Target, rng) Is Nothing _
Or Target.Value = "" _
Then Exit Sub
Set Found = rng.Find(Target.Value)
If Found.Address < Target.Address Then
Target.Select
MsgBox ("Duplicate code")
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
Preventing duplicate data tillytee1 Excel Discussion (Misc queries) 2 March 20th 06 03:49 PM
Copy / Paste Warning wbmcse Excel Discussion (Misc queries) 0 March 3rd 06 07:04 PM
Warning while entering duplicate values in a cell Raj Mazumdar Excel Discussion (Misc queries) 2 February 28th 06 11:05 PM
Macro warning box Quaisne Excel Discussion (Misc queries) 4 October 13th 05 07:45 AM
DUPLICATE VALUES Saintsman Excel Worksheet Functions 2 October 12th 05 05:21 PM


All times are GMT +1. The time now is 02:28 PM.

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

About Us

"It's about Microsoft Excel"