Pulling duplicate data from multiple worksheets

Smoo

New Member
Joined
Sep 15, 2006
Messages
9
Good Afternoon,

I would like to know how to create a macro to search multiple worksheets in a workbook and compile all the duplicates into a report on a separate worksheet. The data in each worksheet is formated the same way:
A B C D
Name Date Time Reason

The names in the A column are what the macro would need to go on to look for duplicates.

:rolleyes:

Thank you,
SMOO
 

Excel Facts

Convert text numbers to real numbers
Select a column containing text numbers. Press Alt+D E F to quickly convert text to numbers. Faster than "Convert to Number"
Hi -

Welcome to Mr. Excel Board.

Does it mean duplicate from any of the worksheet? say you have name John on the first WS and on the 2nd sheet, is it considered duplicates?
 
Upvote 0
Thank you for responding. You are correct; I would like it to pull a duplicate from all worksheets including the first one (original).

Thank you,

SMOO
 
Upvote 0
Hi
try
Code:
Sub test()
Dim ws As Worksheet, wsDup As Worksheet, a, e, myDup(), n As Long
With CreateObject("Scripting.Dictionary")
    .CompareMode = vbTextCompare
    For Each ws In Worksheets
        a = ws.Range("a1",ws.Range("a" & Rows.Count).End(xlUp)).Value
        If Not IsArry(a) Then
            If Not IsEmpty(a) Then
                If Not .exists(a) Then
                    .add a, Empty
                Else
                    n = n + 1
                    ReDim Preserve myDup(1 To n)
                    myDup(n) = a
               End If
               GoTo Next_ws
            End If
        End If
        For Each e In a
            If Not IsEmpty(e) Then
                If Not .exists(e) Then
                     .add e, Empty
                Else
                     If IsEmpty(.item(e)) Then
                         n = n + 1
                         ReDim Preserve myDup(1 To n)
                         myDup(n) = e
                         .item(e) = 1
                     End If
                End If
             End If
         Next
Next_ws:
    Next
End With
On Error Resume Next
Sheets("dups").Delete
On Error GoTo 0
Set wsDup = Sheets.Add(before:=Sheets(1))
wsDup.Name = "dups"
wsDup.Range("a1").Resize(n).Value = Application.Transpose(myDup)
Set wsDup = Nothing
End Sub
 
Upvote 0
Thanks Jindon.
tried your code but got syntax error here;
Code:
Set wsDup = Sheets.Add before:=Sheets(1)
i've fixed it with;
Code:
Set wsDup = Sheets.Add(before:=Sheets(1))

and a typo error here;
Code:
With CreateObject("Scripting.Dictionray")

and object required here;
Code:
        a = ws.Range("a1", ws.Range("a" & Rwos.Count).End(xlUp)).Value
 
Upvote 0

Forum statistics

Threads
1,214,431
Messages
6,119,462
Members
448,899
Latest member
maplemeadows

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top