+ Reply to Thread
Results 1 to 3 of 3

Removing Duplicates across multiple worksheets

Hybrid View

  1. #1
    Registered User
    Join Date
    05-12-2009
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    5

    Removing Duplicates across multiple worksheets

    I'm taking an excel document given to me, running it through a series of queries in Access and exporting the results out via TransferSpreadSheet into Excel. The problem is some of the records meet the criteria of multiple queries. What I'm wanting to do is have an excel macro/vba go through and remove duplicates from the worksheets.

    If possible I would like it to use Column Z for the unique identifer for each record and look through all of the sheets using Column Z from sheet 1, sheet 2, sheet 3, etc and compare them to each other. I found code on this forum but it's not working for me (is probably that I'm doing something wrong)

    Option Explicit
    
    Sub Delete_Duplicate_Rows()
    Dim str1 As String, str2 As String
    Dim r1 As Long, r2 As Long, c As Long
    Dim ws As Worksheet
    
    Application.ScreenUpdating = False
    
    For Each ws In Worksheets
    
        With ws.UsedRange
        
            For r1 = .Rows.Count To 2 Step -1
                str1 = ""
                For c = 1 To .Columns.Count
                    str1 = str1 & Cells(r1, c).Value
                Next c
                    
                For r2 = r1 - 1 To 1 Step -1
                    str2 = ""
                    For c = 1 To .Columns.Count
                        str2 = str2 & Cells(r2, c).Value
                    Next c
            
                    If str1 = str2 Then
                        Rows(r1).Delete
                    Exit For
                    End If
                Next r2
            Next r1
        
        End With
    
    Next ws
    
    Application.ScreenUpdating = True
    End Sub

  2. #2
    Registered User
    Join Date
    05-12-2009
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Removing Duplicates across multiple worksheets

    Can anybody help? I've been searching Google all day and am unable to come up with a resolution.

  3. #3
    Registered User
    Join Date
    05-12-2009
    Location
    Cincinnati
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Removing Duplicates across multiple worksheets

    Spent the night looking, I'm unable to find code for this. I'd greatly appreciate any suggestions to help with this.

+ 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