Identifying Duplicates

weatherman711

New Member
Joined
May 25, 2011
Messages
5
I want to know if there is a way of identifying duplicate entries w/in a column that outputs information from adjacent cells.

Here's my example:
I'm making a bill of materials and every part has a unique ID (column A), yet some of the parts have the same description (column B). I would like a formula or macro that outputs a list of the alternate ID's for each part that has a duplicate description (column C).

_____A______________B___________C_________
1...Part ID........Part Desc.........Alt. Part ID
2...P100...............Bolt...............P100, P355, P865
3...P101...............Hex Nut.........P101, P934
4...P260...............Shaft
5...P355...............Bolt..............P100, P355, P865
6...P356...............Washer
7...P832...............Flange
8...P865...............Bolt..............P100, P355, P865
9...P934...............Hex Nut.........P101, P934


I know about conditional formatting and highlighting duplicates, then using CTRL+F to find the matches and manually inputting matching ID's into a single column (or series of columns), but my list is very long and that would take too much time.

Can anybody help?
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
One way to do this would be to create a few helper tables that would be
quick to do and simple to update.

1. Create a PivotTable based on your original data (hide the total rows).
2. Create a second table with the formulas shown that point to the
PivotTable and effectively create a new lookup table for your alternate IDs.
3. Add a column to your original data to pull in the alternate IDs based
on the part description.

Here is an overview followed by the formulas you would need.

<b>Excel 2003</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>A</th><th>B</th><th>C</th><th>D</th><th>E</th><th>F</th><th>G</th><th>H</th><th>I</th><th>J</th><th>K</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">1</td><td style="font-weight: bold;text-align: center;background-color: #FFFF99;;">Original Data</td><td style="font-weight: bold;text-align: center;background-color: #FFFF99;;"></td><td style="font-weight: bold;text-align: center;background-color: #FFFF99;;"></td><td style="font-weight: bold;text-align: right;;"></td><td style="font-weight: bold;text-align: center;background-color: #CCFFFF;;">Pivot Table</td><td style="font-weight: bold;text-align: center;background-color: #CCFFFF;;"></td><td style="font-weight: bold;text-align: center;background-color: #CCFFFF;;"></td><td style="font-weight: bold;text-align: right;;"></td><td style="font-weight: bold;text-align: center;background-color: #CCFFCC;;">Helper Table</td><td style="font-weight: bold;text-align: center;background-color: #CCFFCC;;"></td><td style="font-weight: bold;text-align: center;background-color: #CCFFCC;;"></td></tr><tr ><td style="color: #161120;text-align: center;">2</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-bottom: 1px solid black;;"></td><td style="text-align: right;border-bottom: 1px solid black;;"></td><td style="text-align: right;border-bottom: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">3</td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">Count of Part Desc</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;"></td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td><td style="text-align: right;;"></td></tr><tr ><td style="color: #161120;text-align: center;">4</td><td style="font-weight: bold;;">Part ID</td><td style="font-weight: bold;;">Part Desc</td><td style="font-weight: bold;;">Alternate IDs</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">Part Desc</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">Part ID</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;;">Total</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="font-weight: bold;;">Label</td><td style="font-weight: bold;;">Part Desc</td><td style="font-weight: bold;;">Alternate IDs</td></tr><tr ><td style="color: #161120;text-align: center;">5</td><td style="background-color: #FFFF99;;">P100</td><td style="background-color: #FFFF99;;">Bolt</td><td style="background-color: #CCFFCC;;">P100, P355, P865</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">Bolt</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">P100</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">1</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="background-color: #CCFFCC;;"></td><td style="background-color: #CCFFCC;;">Bolt</td><td style="background-color: #CCFFCC;;">P100</td></tr><tr ><td style="color: #161120;text-align: center;">6</td><td style="background-color: #FFFF99;;">P101</td><td style="background-color: #FFFF99;;">Hex Nut</td><td style="background-color: #CCFFCC;;">P101, P934</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;"></td><td style="border-right: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">P355</td><td style="text-align: right;border-right: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">1</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="background-color: #CCFFCC;;"></td><td style="background-color: #CCFFCC;;">Bolt</td><td style="background-color: #CCFFCC;;">P100, P355</td></tr><tr ><td style="color: #161120;text-align: center;">7</td><td style="background-color: #FFFF99;;">P260</td><td style="background-color: #FFFF99;;">Shaft</td><td style="background-color: #CCFFCC;;">P260</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;"></td><td style="border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">P865</td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">1</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="background-color: #CCFFCC;;">Bolt</td><td style="background-color: #CCFFCC;;">Bolt</td><td style="background-color: #CCFFCC;;">P100, P355, P865</td></tr><tr ><td style="color: #161120;text-align: center;">8</td><td style="background-color: #FFFF99;;">P355</td><td style="background-color: #FFFF99;;">Bolt</td><td style="background-color: #CCFFCC;;">P100, P355, P865</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">Flange</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">P832</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">1</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="background-color: #CCFFCC;;">Flange</td><td style="background-color: #CCFFCC;;">Flange</td><td style="background-color: #CCFFCC;;">P832</td></tr><tr ><td style="color: #161120;text-align: center;">9</td><td style="background-color: #FFFF99;;">P356</td><td style="background-color: #FFFF99;;">Washer</td><td style="background-color: #CCFFCC;;">P356</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">Hex Nut</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">P101</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">1</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="background-color: #CCFFCC;;"></td><td style="background-color: #CCFFCC;;">Hex Nut</td><td style="background-color: #CCFFCC;;">P101</td></tr><tr ><td style="color: #161120;text-align: center;">10</td><td style="background-color: #FFFF99;;">P832</td><td style="background-color: #FFFF99;;">Flange</td><td style="background-color: #CCFFCC;;">P832</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;"></td><td style="border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">P934</td><td style="text-align: right;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">1</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="background-color: #CCFFCC;;">Hex Nut</td><td style="background-color: #CCFFCC;;">Hex Nut</td><td style="background-color: #CCFFCC;;">P101, P934</td></tr><tr ><td style="color: #161120;text-align: center;">11</td><td style="background-color: #FFFF99;;">P865</td><td style="background-color: #FFFF99;;">Bolt</td><td style="background-color: #CCFFCC;;">P100, P355, P865</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">Shaft</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">P260</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">1</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="background-color: #CCFFCC;;">Shaft</td><td style="background-color: #CCFFCC;;">Shaft</td><td style="background-color: #CCFFCC;;">P260</td></tr><tr ><td style="color: #161120;text-align: center;">12</td><td style="background-color: #FFFF99;;">P934</td><td style="background-color: #FFFF99;;">Hex Nut</td><td style="background-color: #CCFFCC;;">P101, P934</td><td style="text-align: right;border-right: 1px solid black;;"></td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">Washer</td><td style="border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">P356</td><td style="text-align: right;border-top: 1px solid black;border-right: 1px solid black;border-bottom: 1px solid black;border-left: 1px solid black;background-color: #CCFFFF;;">1</td><td style="text-align: right;border-left: 1px solid black;;"></td><td style="background-color: #CCFFCC;;">Washer</td><td style="background-color: #CCFFCC;;">Washer</td><td style="background-color: #CCFFCC;;">P356</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br />

Here are the Helper Table formulas:

<b>Excel 2003</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /><col /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>I</th><th>J</th><th>K</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">5</td><td style="background-color: #CCFFCC;;"></td><td style="background-color: #CCFFCC;;">Bolt</td><td style="background-color: #CCFFCC;;">P100</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">I5</th><td style="text-align:left">=IF(<font color="Blue">J6<>J5,J5,""</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">J5</th><td style="text-align:left">=IF(<font color="Blue">E5<>0,E5,J4</font>)</td></tr><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">K5</th><td style="text-align:left">=IF(<font color="Blue">J5=J4,K4&", "&F5,F5</font>)</td></tr></tbody></table></td></tr></table><br />


Here is the formula for the new Alternate IDs column:

<b>Excel 2003</b><table cellpadding="2.5px" rules="all" style=";background-color: #FFFFFF;border: 1px solid;border-collapse: collapse; border-color: #A6AAB6"><colgroup><col width="25px" style="background-color: #E0E0F0" /><col /></colgroup><thead><tr style=" background-color: #E0E0F0;text-align: center;color: #161120"><th></th><th>C</th></tr></thead><tbody><tr ><td style="color: #161120;text-align: center;">5</td><td style="background-color: #CCFFCC;;">P100, P355, P865</td></tr></tbody></table><p style="width:3.6em;font-weight:bold;margin:0;padding:0.2em 0.6em 0.2em 0.5em;border: 1px solid #A6AAB6;border-top:none;text-align: center;background-color: #E0E0F0;color: #161120">Sheet1</p><br /><br /><table width="85%" cellpadding="2.5px" rules="all" style=";border: 2px solid black;border-collapse:collapse;padding: 0.4em;background-color: #FFFFFF" ><tr><td style="padding:6px" ><b>Worksheet Formulas</b><table cellpadding="2.5px" width="100%" rules="all" style="border: 1px solid;text-align:center;background-color: #FFFFFF;border-collapse: collapse; border-color: #A6AAB6"><thead><tr style=" background-color: #E0E0F0;color: #161120"><th width="10px">Cell</th><th style="text-align:left;padding-left:5px;">Formula</th></tr></thead><tbody><tr><th width="10px" style=" background-color: #E0E0F0;color: #161120">C5</th><td style="text-align:left">=VLOOKUP(<font color="Blue">B5,$I$5:$K$12,3,FALSE</font>)</td></tr></tbody></table></td></tr></table><br />


Let us know if this works.

Gary
 
Last edited:
Upvote 0
Hi

Welcome to MrExcel.

I'm not an expert and this method does have some draw backs.
You will need to use some additional columns and the results are not perfect, this is due to me not being able to Concatenate an unknown range.


Excel Workbook
ABCDEF
1Part IDPart DescAlt Part IDAdditional Columns
2P100BoltP100, P355, P865,P100P355P865
3P101Hex NutP101, P934, ,P101P934
4P260ShaftP260
5P355BoltP100, P355, P865,P100P355P865
6P356WasherP356
7P832FlangeP832
8P865BoltP100, P355, P865,P100P355P865
9P934Hex NutP101, P934, ,P101P934
Sheet2




The formula in C2 needs to be copied down.
The formula in D2 needs entering with ctrl shift enter NOT enter.
You can the copy it across and down.

You will need to change the cell reference to suit.

I hope this gives you some help or ideas.

Good luck

Ak
 
Last edited:
Upvote 0
Thanks GaryWMn and Akashwani!

GaryWMn - I just started using Excel 2010 and the pivot table formatting is a little different than 2003. I'm new to pivot tables and I got a little bogged down in trying to arrange the data, but the output I obtained was still useful.

Akashwani - Your method works very well, I actually wanted to have all the alternate ID's in separate columns for exporting purposes and your method did that. My BoM has about 10,000 parts to it and I was quickly able to match up all the interchangeable parts - time to ask for a raise! lol

Thanks again guys
 
Upvote 0
Hi,

Thanks for the feedback.
I'm sorry that my method wasn't perfect, but I'm fairly sure the only way to get a perfect concatenated solution is with VBA.
You could try searching the net for....
Excel VBA concatenate range
Or start a new thread and ask the question.

By the way, good luck with the raise :rofl:

Ak
 
Upvote 0
Hey Ak,

After spending a little time inspecting my spreadsheet, I've noticed some irregularities. Sometimes a part ID is output to column D, but there are no subsequent outputs. If there was a duplicate description, shouldn't there always be >1 part ID's? Below is an example of this in row 64. Rows 65-69 seem to be OK...

Excel Workbook
ABCDE
64FR705.0161486G-0 3/4'' SOLENOID SHUTOFF VALVE*FR705.016*
65FR705.0171821A-0 3/4'' BALL VALVEFR705.017, FR705.021, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,FR705.017FR705.021
66FR705.018R130-5851 SELF CHECKING ULTRAVIOLET DETECTOR***
67FR705.0198835-R 3/4'' MPT FLAME SUP ADAPTOR***
68FR705.0201808-01 1/2'' BRASS VALVE***
69FR705.0211821A-0 3/4'' BALL VALVEFR705.017, FR705.021, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,FR705.017FR705.021
Sheet1


Also, sometimes I find that not all the matches are shown. The example below should have 3 duplicate parts listed, but for some reason, it's not listing itself, and it's corresponding matches dont list ID# FR705.058 either. Any clue as to what's going on?

 
Upvote 0
Hi,

Without seeing your complete sheet I couldn't say what is wrong.
I assume your ranges extend to the end of your data.
There could be a spelling error, space, number or some other reason why the count isn't greater than 1.

Excel Workbook
BCD
3DescriptionLengthCountif
41821A-0 3/4'' BALL VALVE242
51821A-0 3/4'' BALLVALVE231
61821A -0 3/4'' BALL VALVE251
71821A-0 3/4'' *BALL *VALVE261
81821A-0 3/4'' BALL VALVE242
Sheet1


You can PM me your email address and I will take a look at your file for you, but I can't promise anything, I'm not an expert.

Ak
 
Upvote 0
Hi weatherman711,

Specifically relating to your opening post, does this macro (you said maybe a macro) do what you want?
Code:
Sub Altparts()
Dim a, nr&, i&, c()
Dim d As Object, k&
a = Range("A1").CurrentRegion
nr = UBound(a, 1)
ReDim c(1 To nr, 1 To 1)
Set d = CreateObject("scripting.dictionary")
d.comparemode = 1

For i = 1 To nr
    If d(a(i, 2)) = Empty Then
        d(a(i, 2)) = a(i, 1)
    Else
        d(a(i, 2)) = d(a(i, 2)) & ", " & a(i, 1)
    End If
Next i

c(1, 1) = "Alt Part ID"
For i = 2 To nr
    If InStr(d(a(i, 2)), ",") > 0 Then c(i, 1) = d(a(i, 2))
Next i
[c1].Resize(nr) = c
End Sub
 
Upvote 0
Hi Mirabeau,

Wow, I really must learn vba.
Based on my sample data, that code is PERFECT, amazing, really amazing.

Thanks

Ak
 
Upvote 0
Hey Mirabeau,

So I inserted a class module in vba and saved it, but where do I go from there to run the macro?

Hi weatherman711,

Specifically relating to your opening post, does this macro (you said maybe a macro) do what you want?
Code:
Sub Altparts()
Dim a, nr&, i&, c()
Dim d As Object, k&
a = Range("A1").CurrentRegion
nr = UBound(a, 1)
ReDim c(1 To nr, 1 To 1)
Set d = CreateObject("scripting.dictionary")
d.comparemode = 1

For i = 1 To nr
    If d(a(i, 2)) = Empty Then
        d(a(i, 2)) = a(i, 1)
    Else
        d(a(i, 2)) = d(a(i, 2)) & ", " & a(i, 1)
    End If
Next i

c(1, 1) = "Alt Part ID"
For i = 2 To nr
    If InStr(d(a(i, 2)), ",") > 0 Then c(i, 1) = d(a(i, 2))
Next i
[c1].Resize(nr) = c
End Sub
 
Upvote 0

Forum statistics

Threads
1,224,544
Messages
6,179,430
Members
452,915
Latest member
hannnahheileen

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