Results 1 to 3 of 3
  1. #1
    Bronze Lounger
    Join Date
    Sep 2007
    Posts
    1,203
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I need to check for duplicates in a (sorted) range, but I am not sure how?

    Code:
    x5 = w5.Cells(w5.Rows.Count, 1).End(xlUp).Row		'last value (row number)
    
    	Set y5 = w5.Range("J3:J" & x5)
    	
    	For Each RngFind In y5
    		If Len(RngFind) <> 16 Then
    			RngFind.Offset(0, 1) = "LEN ERROR"
    		ElseIf Left(RngFind, 6) = "456789" Then
    			RngFind.Offset(0, 2) = "XYZ"
    		Else
    			'Look for duplicates, mark up the 2nd onwards
    			RngFind.Offset(0, 3) = "DUPLICATE"
    		End If
    	Next
    If RngFind (J20) = RngFind (J19) Then.....

    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Try this:

    Code:
    dim r as long
    r = rngfind.row
    if application.countif(w5.range("j3:j" & r), rngfind) > 1 then
      rngfind.offset(0, 3) = "DUPLICATE"
    end if

  3. #3

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •