Use Equations to find duplicates and sort KEEPING the duplicates

Zanatos1986

New Member
Joined
Apr 15, 2010
Messages
48
I want to do this in equation form -
Column D has a date, everything has been sorted by this date (newest to oldest)
Column B has a part number, there can be the same part number at multiple dates.
Find any duplicates in column B, and move them so that they are in order and all values are kept.

Pictorial example:

image.jpg
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I cannot see the picture due to 3rd party settings

Is this something that can be done using conditional formatting to highlight duplicates

I'm not sure what you mean by sort them, are you meaning if the same part is bought multiple times on the same day you'd like them to show beneath each other on the spreadsheet within the date?
 
Upvote 0
I also can't see the picture, but from your description, this might be what you're looking for:

ABCDEFG
1PartDatePartDate
2a11-Jana11-Jan
3b21-Feba11-Mar
4a11-Marb21-Feb
5z91-Aprb21-May
6b21-Mayd81-Aug
7z91-Jung41-Jul
8g41-Julz91-Apr
9d81-Augz91-Jun
10

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet5

Array Formulas
CellFormula
F2{=INDEX(B:B,MIN(IF(B2:B20<>"",IF(COUNTIF(B2:B20,"<"&B2:B20)=0,ROW(B2:B20)))))}
F3{=IF(COUNTIF($F$2:$F2,F2)<COUNTIF($B$2:$B$20,F2),F2,IF(ROW()>COUNTA($B:$B),"",INDEX(B:B,MIN(IF(COUNTIF($B$2:$B$20,"<"&$B$2:$B$20)=ROW()-2,ROW($B$2:$B$20))))))}
G2{=IF(F2="","",INDEX(D:D,SMALL(IF($B$2:$B$20=F2,ROW($B$2:$B$20)),COUNTIF($F$2:$F2,F2))))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



Put the F2 formula in, change the ranges to match your sheet, confirm with Control+Shift+Enter. Repeat with the F3 formula, then drag down. Repeat with the G2 formula, then drag down. Let us know if this is what you have in mind.
 
Upvote 0
I also can't see the picture, but from your description, this might be what you're looking for:

ABCDEFG
1PartDatePartDate
2a11-Jana11-Jan
3b21-Feba11-Mar
4a11-Marb21-Feb
5z91-Aprb21-May
6b21-Mayz91-Apr
7z91-Junz91-Jun
8g41-Julg41-Jul
9d81-Augd81-Aug
10

<tbody>
</tbody>

What you have is close, I changed the bottom 4 cells. The date is more vital to stay in order than the part number. It's just moving the duplicates up and keeping the overall date in order.
 
Upvote 0
OK, it sounds like you don't want the part numbers sorted alphabetically (numerically), you want them listed in the order they're found, just grouped. Try this:

ABCDEFG
1PartDatePartDate
2a11-Jana11-Jan
3b21-Feba11-Mar
4a11-Marb21-Feb
5z91-Aprb21-May
6b21-Mayz91-Apr
7z91-Junz91-Jun
8g41-Julg41-Jul
9d81-Augd81-Aug
10

<colgroup><col style="width: 25pxpx"><col><col><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet7

Worksheet Formulas
CellFormula
F2=B2

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>

Array Formulas
CellFormula
F3{=IF(COUNTIF($F$2:$F2,F2)<COUNTIF($B$2:$B$20,F2),F2,IF(ROW()>COUNTA($B:$B),"",INDEX(B:B,MIN(IF(COUNTIF($F$2:$F2,$B$2:$B$20)=0,ROW($B$2:$B$20))))))}
G2{=IF(F2="","",INDEX(D:D,SMALL(IF($B$2:$B$20=F2,ROW($B$2:$B$20)),COUNTIF($F$2:$F2,F2))))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>



The F2 and F3 formulas have changed, G2 is the same.
 
Upvote 0
Is there an issue with F3? I am inserting it exactly as you are but get an error "There's a problem with this formula. Not trying to type a formula? ...."
Error occurs at...
=IF(<font color="Blue" style="background-color: rgb(250, 250, 250);">COUNTIF($F$2:$F2,F2)<countif(<font color="Red">$B$2</countif(
 
Upvote 0
The F3 formula should be:

Code:
=IF(COUNTIF($F$2:$F2,F2)< COUNTIF($B$2:$B$20,F2),F2,IF(ROW()>COUNTA($B:$B),"",INDEX(B:B,MIN(IF(COUNTIF($F$2:$F2,$B$2:$B$20)=0,ROW($B$2:$B$20))))))

The forum software here sometimes interprets a < as an HTML tag instead of part of a formula. I checked for that before posting, but somehow that one got past me. Sorry. Let me know if this works.
 
Upvote 0

Forum statistics

Threads
1,214,833
Messages
6,121,857
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