+ Reply to Thread
Results 1 to 4 of 4

Identify Duplicates (was Delete Duplicates)

Hybrid View

  1. #1
    Registered User
    Join Date
    04-28-2011
    Location
    St. Louis
    MS-Off Ver
    Excel 2007
    Posts
    21

    Identify Duplicates (was Delete Duplicates)

    NOTE: The title of this thread is misleading. . . instead, it should be "IDENTIFY DUPLICATES". So for any confusion.

    I have a spreadsheet, organized in two data arrays:
    1 - Data array: A1:G1500
    2 - Data array: J1:N1500

    I'd like to look at row A1:G1 and see if that data exists in array J1:N1500
    - If it is UNIQUE, highlight the data set in J1:N1500.
    - If it is DUPLICATED, build an array of that duplicate data in R1:Wxxx

    Attached is an example of the data sets and results that I'd like to achieve.

    As always, thanks in advance!
    Attached Files Attached Files
    Last edited by BusyEvent; 05-11-2011 at 08:13 AM. Reason: Title is Wrong

  2. #2
    Forum Expert Bob Phillips's Avatar
    Join Date
    09-03-2005
    Location
    Wessex
    MS-Off Ver
    Office 2003, 2010, 2013, 2016, 365
    Posts
    3,284

    Re: Identify Duplicates (was Delete Duplicates)

    Public Sub ProcessData()
    Dim LastrowA As Long
    Dim LastrowJ As Long
    Dim Nextrow As Long
    Dim i As Long, j As Long
    Dim FirstCell As String
    Dim Matched As Boolean
    Dim cell As Range
    
        Application.ScreenUpdating = False
        
        With ActiveSheet
        
            LastrowA = .Cells(.Rows.Count, "A").End(xlUp).Row
            LastrowJ = .Cells(.Rows.Count, "J").End(xlUp).Row
            For i = 2 To LastrowJ
            
                Set cell = Nothing
                Matched = False
                Set cell = .Columns("A").Find(.Cells(i, "J").Value2)
                Nextrow = 1
                Matched = False
                If Not cell Is Nothing Then
                
                    FirstCell = cell.Address
                    Do
                    
                        Matched = (.Cells(cell.Row, "B").Value2 = .Cells(i, "K").Value2) And _
                                  (LCase(.Cells(cell.Row, "C").Value2) = LCase(.Cells(i, "L").Value2)) And _
                                  (.Cells(cell.Row, "D").Value2 = .Cells(i, "M").Value2) And _
                                  (.Cells(cell.Row, "E").Value2 = .Cells(i, "N").Value2) And _
                                  (.Cells(cell.Row, "F").Value2 = .Cells(i, "O").Value2)
                        
                        Set cell = .Columns("A").FindNext(cell)
                    Loop Until cell Is Nothing Or cell.Address = FirstCell
                End If
                    
                If Matched Then
                
                    Nextrow = Nextrow + 1
                    .Cells(i, "J").Resize(, 6).Copy .Cells(Nextrow, "R")
                Else
                
                    .Cells(i, "J").Resize(, 6).Interior.ColorIndex = 15 'Copy .Cells(Nextrow, "R")
                End If
            Next i
        End With
        
        Application.ScreenUpdating = True
    End Sub

  3. #3
    Registered User
    Join Date
    04-28-2011
    Location
    St. Louis
    MS-Off Ver
    Excel 2007
    Posts
    21

    Re: Identify Duplicates (was Delete Duplicates)

    Hi Bob...thanks for replying.

    That's more than a bit over my head...I was hoping to see something like "=if(....)"

    How do I use what you've put in?

    Do I paste into a cell? Or run on a SQL database, or ???

  4. #4
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: Identify Duplicates (was Delete Duplicates)

    Use Alt F11 to enter VBA editor.
    Insert>Module and paste Bob's code into the module

    To run: View > Macros>
    From that window, you can click on options and assign a shortcut key if you like.
    Does that help?
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1