Extract Duplicate Values from range and Display them

Trev752

New Member
Joined
Aug 15, 2022
Messages
7
Office Version
  1. 365
Platform
  1. Windows
We have a locker lottery at work, where locker numbers are drawn on a 10-week basis. Within those 10 weeks the same locker number can be drawn multiple times. But, those locker numbers which have been drawn more than once, in those 10 weeks, are not eligible for the next 10 weeks.



I need to extract those duplicate lockers by division and display them separately (Horizontally) so they can be printed.

How can I do this in excel.
 

Attachments

  • Screenshot 2024-03-28 140044.png
    Screenshot 2024-03-28 140044.png
    52.9 KB · Views: 11

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
It is hard to work with a picture. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. 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
It is hard to work with a picture. It would be easier to help if you could use the XL2BB add-in (icon in the menu) to attach a screenshot (not a picture) of your sheet. 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).
Thanks, I'm not to familiar with BOX.com but I'll give it a try
 
Upvote 0
Try:
VBA Code:
Sub findDups()
    Application.ScreenUpdating = False
    Dim v As Variant, e As Variant, arrL1 As Object, arrL2 As Object, col1 As Long, col2 As Long: col1 = 10: col2 = 10
    With Range("J5:O5,J9:O9")
        .ClearContents
        .Interior.ColorIndex = xlNone
    End With
    v = Range("D5:H14").Value
    Set arrL1 = CreateObject("System.Collections.ArrayList")
    Set arrL2 = CreateObject("System.Collections.ArrayList")
    For Each e In v
        If Not arrL1.Contains(e) Then
            arrL1.Add e
        Else
            If Not arrL2.Contains(e) Then arrL2.Add e
        End If
    Next
    arrL2.Sort
    For Each v In arrL2
        If v < 151 Then
            With Cells(5, col1)
                .Value = v
                .Interior.ColorIndex = 3
                .Font.Color = vbWhite
                .Font.Bold = True
            End With
            col1 = col1 + 1
        Else
            With Cells(9, col2)
                .Value = v
                .Interior.ColorIndex = 3
                .Font.Color = vbWhite
                .Font.Bold = True
            End With
            col2 = col2 + 1
        End If
    Next v
    Application.ScreenUpdating = True
End Sub
 
Upvote 0
What about a formula approach?

Trev752.xlsx
CDEFGHIJKLMNO
3North Division
4MonTueWedThuFriLockers1to 150
5Week 127719698139141484127
6Week 2249189115111160
7Week 31237184145237South Division
8Week 463218264239228Lockers151to300
9Week 51411234164194196240277
10Week 68417424074242
11Week 724014688633
12Week 822169263127254
13Week 9127277250117144
14Week 1013619627818018
Sheet1
Cell Formulas
RangeFormula
J5:L5J5=LET(r,D5:H14,v,TOROW(IF(r<151,IF(COUNTIF(r,r)>1,r,""),"")),SORT(UNIQUE(FILTER(v,v<>"",""),1),,,1))
J9:L9J9=LET(r,D5:H14,v,TOROW(IF(r>150,IF(COUNTIF(r,r)>1,r,""),"")),SORT(UNIQUE(FILTER(v,v<>"",""),1),,,1))
Dynamic array formulas.
Named Ranges
NameRefers ToCells
N_1=Sheet1!$D$5:$D$10J9, J5
Cells with Conditional Formatting
CellConditionCell FormatStop If True
D5:H14Cell ValueduplicatestextNO
 
Upvote 0

Forum statistics

Threads
1,223,275
Messages
6,171,119
Members
452,381
Latest member
Nova88

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