Finding Duplicate values from multiple sheets, then creating a new sheet and with all the duplicates and what sheets are the duplicates in?

krishssagar

New Member
Joined
Feb 15, 2023
Messages
1
Office Version
  1. 2016
Platform
  1. Windows
Hey guys! Hope all is well. Cant figure out on how to display the duplicate values and most importantly the code on how to display on what sheets they are present in? Duplicate value can be present in multiple sheets. Let us say the value "1" is present in sheets 1,5,7. On the new sheet I would have two columns which has Duplicates and On what sheets they are present.

So far the code I have is:

Code:
Sub acctDup()
Dim sh As Worksheet, sumsh As Worksheet, lr As Long, c As Range, cnt As Long, i As Long, rng As Range
Sheets.Add Before:=ThisWorkbook.Sheets(1)
Set sumsh = ActiveSheet
sumsh.Range("A1:A2") = "x"
    For Each sh In ThisWorkbook.Sheets
        If sh.Name <> sumsh.Name Then
            lr = sh.Cells(Rows.Count, 1).End(xlUp).Row
            sh.Range("A2:B" & lr).Copy sumsh.Cells(Rows.Count, 1).End(xlUp)(2)
        End If
    Next
Set rng = sumsh.Range("A3", sumsh.Cells(Rows.Count, 1).End(xlUp))
    With sumsh
        For i = .Cells(Rows.Count, 1).End(xlUp).Row To 3 Step -1
            If Application.CountIf(rng, .Cells(i, 1).Value) < 3 Then
                Rows(i).Delete
            Else
                .Range("A2", .Cells(Rows.Count, 2).End(xlUp)).AutoFilter 1, .Cells(i, 1).Value
                cnt = rng.SpecialCells(xlCellTypeVisible).Count
                If cnt >= 3 Then
                    .Cells(i, 3) = cnt
                    .Range("A3", .Cells(i - 1, 2)).SpecialCells(xlCellTypeVisible).EntireRow.Delete
                End If
                .AutoFilterMode = False
                i = i + 1 - cnt
                cnt = 0
            End If
        Next
    End With
End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach screenshots (not pictures) of at least two of your sheets. Alternately, you could upload a copy of your file to a free site such as www.box.com or www.dropbox.com. Once you do that, mark it for 'Sharing' and you will be given a link to the file that you can post here. Explain in detail what you want to do referring to specific cells, rows, columns and sheets using a few examples from your data (de-sensitized if necessary).
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,843
Members
449,051
Latest member
excelquestion515

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