find 1st, 2nd and 3rd small dates in column for same code in other column

zuriqi

Board Regular
Joined
Dec 8, 2008
Messages
79
Hi,

I am looking for a formula to find the 1st, 2nd and 3rd smallest value for the date of the "Date" column which has the same code in "Code" column. Formula to give space if cell in "Date" Column is empty or if code is repeated in column C, D or E. as shown in the table below.


ABCDE
1DateCode1st Small2nd Small3rd Small
201-Oct-17A
3-Jul-17

<tbody>
</tbody>
1-Oct-17

<tbody>
</tbody>
15-Oct-17

<tbody>
</tbody>
301-Oct-17A


4
4-Jan-17

<tbody>
</tbody>
B
4-Jan-17

<tbody>
</tbody>
19-Aug-17

<tbody>
</tbody>

5
6-Aug-17

<tbody>
</tbody>
D
6-Feb-17

<tbody>
</tbody>
1-Jun-17

<tbody>
</tbody>
6-Aug-17

<tbody>
</tbody>
6
5-May-17

<tbody>
</tbody>
C
5-May-17

<tbody>
</tbody>


7
15-Oct-17

<tbody>
</tbody>
A


8
B


9
1-Jun-17

<tbody>
</tbody>
D


10
6-Feb-17

<tbody>
</tbody>
D


11
C


12
19-Aug-17

<tbody>
</tbody>
B


13
3-Jul-17

<tbody>
</tbody>
A


<tbody>
</tbody>
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Put this formula in C2:

Code:
=IFERROR(IF(COUNTIF($B$2:$B4,$B4)>1,"",SMALL(IF(($B$2:$B$13=$B4)*($A$2:$A$13<>""),IF(ISERROR(MATCH($A$2:$A$13,$B4:B4,0)),$A$2:$A$13)),1)),"")
change the ranges to match your sheet, and confirm with Control+Shift+Enter.

Then drag it down and across as needed.
 
Upvote 0
In C2 control+shift+enter, not just enter, copy across, and down:

=IF(ISNA(MATCH($B2,$B$1:$B1,0)),IFERROR(IF(MIN(IF($B$2:$B$13=$B2,IF(ISNUMBER(1/$A$2:$A$13),IF(ISNA(MATCH($A$2:$A$13,$B2:B2,0)),$A$2:$A$13))))=0,"",MIN(IF($B$2:$B$13=$B2,IF(ISNUMBER(1/$A$2:$A$13),IF(ISNA(MATCH($A$2:$A$13,$B2:B2,0)),$A$2:$A$13))))),""),"")

If you would want to custom format the formula cell as follows:

[=0]"";d-mmm-yy

you can in C2 control+shift+enter, not just enter, copy across, and down:

=IF(ISNA(MATCH($B2,$B$1:$B1,0)),IFERROR(MIN(IF($B$2:$B$13=$B2,IF(ISNUMBER(1/$A$2:$A$13),IF(ISNA(MATCH($A$2:$A$13,$B2:B2,0)),$A$2:$A$13,"")))),""),"")
 
Upvote 0
Great Aladin, it works like charm , what about the 2nd small and 3rd ? i mean formula in D2 and E2?
 
Upvote 0
Woow thanks a lot Aladin , you really solve an issue in my database.. Thank you very much
 
Upvote 0

Forum statistics

Threads
1,215,669
Messages
6,126,117
Members
449,292
Latest member
Mario BR

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