closest two dates to today

Mandy_84

Board Regular
Joined
May 29, 2017
Messages
71
Hi
Desperately need a help to find two closest dates to today from the list of different people and dates. So the column C & D should show as follows. [TABLE="width: 500"]
<tbody>[TR]
[TD][/TD]
[TD]a[/TD]
[TD]b[/TD]
[TD]c[/TD]
[TD]d[/TD]
[TD]e[/TD]
[/TR]
[TR]
[TD]1[/TD]
[TD]Nick[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl63, width: 94, align: right"]9/1/2016[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]1/1/2017[/TD]
[TD]10/1/2017[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]2[/TD]
[TD]Nick[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl65, width: 94, align: right"]1/1/2017[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]3[/TD]
[TD]Nick[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl65, width: 94, align: right"]10/1/2017[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]4[/TD]
[TD]John[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl65, width: 94, align: right"]12/1/2016[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]12/1/2016[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]5[/TD]
[TD]Mary[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl65, width: 94, align: right"]8/1/2017[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]1/1/2017[/TD]
[TD]8/1/2017[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]6[/TD]
[TD]Mary[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl65, width: 94, align: right"]12/1/2015[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]7[/TD]
[TD]Mary[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl65, width: 94, align: right"]9/1/2016[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]8[/TD]
[TD]Mary[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl65, width: 94, align: right"]1/1/2017[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]0[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
[TR]
[TD]9[/TD]
[TD]Izabella[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl65, width: 94, align: right"]9/1/2016[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 94"]
<tbody>[TR]
[TD="class: xl65, width: 94, align: right"]9/1/2016[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD]0[/TD]
[TD][/TD]
[/TR]
</tbody>[/TABLE]

Thanks a lot!!!!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If the dates will never be in the future then this should work

Excel 2010
ABCD
Nick
Nick
Nick
John
Mary
Mary
Mary
Mary
Izabella

<colgroup><col><col><col><col><col></colgroup><thead>
</thead><tbody>
[TD="align: center"]1[/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]
[TD="align: right"][/TD]

[TD="align: center"]2[/TD]

[TD="align: right"]9/1/2016[/TD]
[TD="align: right"]1/1/2017[/TD]
[TD="align: right"]10/1/2017[/TD]

[TD="align: center"]3[/TD]

[TD="align: right"]1/1/2017[/TD]

[TD="align: center"]4[/TD]

[TD="align: right"]10/1/2017[/TD]

[TD="align: center"]5[/TD]

[TD="align: right"]12/1/2016[/TD]
[TD="align: right"]12/1/2016[/TD]

[TD="align: center"]6[/TD]

[TD="align: right"]8/1/2017[/TD]
[TD="align: right"]1/1/2017[/TD]
[TD="align: right"]8/1/2017[/TD]

[TD="align: center"]7[/TD]

[TD="align: right"]12/1/2015[/TD]

[TD="align: center"]8[/TD]

[TD="align: right"]9/1/2016[/TD]

[TD="align: center"]9[/TD]

[TD="align: right"]1/1/2017[/TD]

[TD="align: center"]10[/TD]

[TD="align: right"]9/1/2016[/TD]
[TD="align: right"]9/1/2016[/TD]

</tbody>
Sheet1

[TABLE="width: 85%"]
<tbody>[TR]
[TD]Array Formulas[TABLE="width: 100%"]
<thead>[TR="bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]
[TH="width: 10"]Cell[/TH]
[TH="align: left"]Formula[/TH]
[/TR]
</thead><tbody>[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C2[/TH]
[TD="align: left"]{=IF(A2<>A1,IF(COUNTIF($A$2:$A$10,A2)>1,LARGE(IF($A$2:$A$10=A2,$B$2:$B$10,"n"),2),LARGE(IF($A$2:$A$10=A2,$B$2:$B$10,"n"),1)),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D2[/TH]
[TD="align: left"]{=IF(A2<>A1,IF(COUNTIF($A$2:$A$10,A2)>1,LARGE(IF($A$2:$A$10=A2,$B$2:$B$10,"n"),1),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C3[/TH]
[TD="align: left"]{=IF(A3<>A2,IF(COUNTIF($A$2:$A$10,A3)>1,LARGE(IF($A$2:$A$10=A3,$B$2:$B$10,"n"),2),LARGE(IF($A$2:$A$10=A3,$B$2:$B$10,"n"),1)),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D3[/TH]
[TD="align: left"]{=IF(A3<>A2,IF(COUNTIF($A$2:$A$10,A3)>1,LARGE(IF($A$2:$A$10=A3,$B$2:$B$10,"n"),1),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C4[/TH]
[TD="align: left"]{=IF(A4<>A3,IF(COUNTIF($A$2:$A$10,A4)>1,LARGE(IF($A$2:$A$10=A4,$B$2:$B$10,"n"),2),LARGE(IF($A$2:$A$10=A4,$B$2:$B$10,"n"),1)),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D4[/TH]
[TD="align: left"]{=IF(A4<>A3,IF(COUNTIF($A$2:$A$10,A4)>1,LARGE(IF($A$2:$A$10=A4,$B$2:$B$10,"n"),1),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C5[/TH]
[TD="align: left"]{=IF(A5<>A4,IF(COUNTIF($A$2:$A$10,A5)>1,LARGE(IF($A$2:$A$10=A5,$B$2:$B$10,"n"),2),LARGE(IF($A$2:$A$10=A5,$B$2:$B$10,"n"),1)),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D5[/TH]
[TD="align: left"]{=IF(A5<>A4,IF(COUNTIF($A$2:$A$10,A5)>1,LARGE(IF($A$2:$A$10=A5,$B$2:$B$10,"n"),1),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C6[/TH]
[TD="align: left"]{=IF(A6<>A5,IF(COUNTIF($A$2:$A$10,A6)>1,LARGE(IF($A$2:$A$10=A6,$B$2:$B$10,"n"),2),LARGE(IF($A$2:$A$10=A6,$B$2:$B$10,"n"),1)),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D6[/TH]
[TD="align: left"]{=IF(A6<>A5,IF(COUNTIF($A$2:$A$10,A6)>1,LARGE(IF($A$2:$A$10=A6,$B$2:$B$10,"n"),1),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C7[/TH]
[TD="align: left"]{=IF(A7<>A6,IF(COUNTIF($A$2:$A$10,A7)>1,LARGE(IF($A$2:$A$10=A7,$B$2:$B$10,"n"),2),LARGE(IF($A$2:$A$10=A7,$B$2:$B$10,"n"),1)),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D7[/TH]
[TD="align: left"]{=IF(A7<>A6,IF(COUNTIF($A$2:$A$10,A7)>1,LARGE(IF($A$2:$A$10=A7,$B$2:$B$10,"n"),1),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C8[/TH]
[TD="align: left"]{=IF(A8<>A7,IF(COUNTIF($A$2:$A$10,A8)>1,LARGE(IF($A$2:$A$10=A8,$B$2:$B$10,"n"),2),LARGE(IF($A$2:$A$10=A8,$B$2:$B$10,"n"),1)),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D8[/TH]
[TD="align: left"]{=IF(A8<>A7,IF(COUNTIF($A$2:$A$10,A8)>1,LARGE(IF($A$2:$A$10=A8,$B$2:$B$10,"n"),1),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C9[/TH]
[TD="align: left"]{=IF(A9<>A8,IF(COUNTIF($A$2:$A$10,A9)>1,LARGE(IF($A$2:$A$10=A9,$B$2:$B$10,"n"),2),LARGE(IF($A$2:$A$10=A9,$B$2:$B$10,"n"),1)),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D9[/TH]
[TD="align: left"]{=IF(A9<>A8,IF(COUNTIF($A$2:$A$10,A9)>1,LARGE(IF($A$2:$A$10=A9,$B$2:$B$10,"n"),1),""),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]C10[/TH]
[TD="align: left"]{=IF(A10<>A9,IF(COUNTIF($A$2:$A$10,A10)>1,LARGE(IF($A$2:$A$10=A10,$B$2:$B$10,"n"),2),LARGE(IF($A$2:$A$10=A10,$B$2:$B$10,"n"),1)),"")}[/TD]
[/TR]
[TR]
[TH="width: 10, bgcolor: [URL=https://www.mrexcel.com/forum/usertag.php?do=list&action=hash&hash=DAE7F5]#DAE7F5[/URL] "]D10[/TH]
[TD="align: left"]{=IF(A10<>A9,IF(COUNTIF($A$2:$A$10,A10)>1,LARGE(IF($A$2:$A$10=A10,$B$2:$B$10,"n"),1),""),"")}[/TD]
[/TR]
</tbody>[/TABLE]
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself[/TD]
[/TR]
</tbody>[/TABLE]
 
Upvote 0
Thanks, I eventually used following function

<today(),$b$1:$b$9))),if($a$1:$a$9=n1,$b$1:$b$9),0))
=INDEX($B$1:$B$9,MATCH(MAX(IF($A$1:$A$9=N1,IF($B$1:$B$9<today(),$b$1:$b$9))),if($a$1:$a$9=n1,$b$1:$b$9),0))
<TODAY(),$B$1:$B$9))),IF($A$1:$A$9=N1,$B$1:$B$9),0))

where Column N consist of names</today(),$b$1:$b$9))),if($a$1:$a$9=n1,$b$1:$b$9),0))
</today(),$b$1:$b$9))),if($a$1:$a$9=n1,$b$1:$b$9),0))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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