How to rank dates in excel on a large group with duplicates, triplicates, and quadruplicates

rosafranco2020

New Member
Joined
Oct 9, 2020
Messages
12
Office Version
  1. 365
Platform
  1. Windows
Hi all,

I need your expertise! Below is just a sample, but I am working on a larger volume of data containing duplicates, triplicates, and quadruplicates in which I need the newest and second to the newest date records only. I tried using the RANK.EQ function so it gives me 1,2,3,4 etc. and at the end I can filter by 1 & 2 which should be the newest & second newest dates and then copy and paste that into my final report. But the formula I am using (i.e. =RANK.EQ(C2,C$2:C$4) is not working for this large data sheet. I basically need the function to look at the Member SSN since that will drive who/what on the column after "Thru Date" Any ideas that you have will be extremely helpful. Since I am new as of yesterday, I can't get the XL2BB to work. I am so sorry! I am hoping someone can still help me please. Thank you for your time!
Member SSNAccountMember IDFirst NameLast NameDOBFrom DateThru Date
123434697Active0123ParisFrance01/01/199102/01/201902/28/2019
123434697Active0123ParisFrance01/01/199103/01/201908/01/2019
123434697Active0123ParisFrance01/01/199108/01/201912/31/2039
478908765Active0987BudLight03/23/196511/01/202012/31/2039
478908765Active0987BudLight03/23/196506/01/201910/30/2020
908239089Active8765CoronaVirisu07/23/195609/01/202009/30/2020
908239089Active8765CoronaVirisu07/23/195610/01/202012/31/2039
089092345Active3454ZenVu4/15/198010/01/202012/31/2039
089092345Active3454ZenVu4/15/198001/01/201909/30/2020
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Let's get the ball rolling. Now I am going to go the VBA route first. I am going to see if I can figure a formula or function next. This should generate a discussion and lots of questions. But we have to start some place. Look this over and let us know if it's what you were thinking.

VBA Code:
Option Explicit

Sub DateSort1()

Dim firstrow As Long
Dim lastrow As Long
Dim myrange As Range
Dim outrow As Long

firstrow = 2
outrow = 2
Cells(1, 10) = "SSN"
Cells(1, 11) = "1st Date"
Cells(1, 12) = "2nd Date"


Do Until Cells(firstrow, 1) = ""
lastrow = firstrow
    Do Until Cells(lastrow, 1) <> Cells(lastrow + 1, 1)
    lastrow = lastrow + 1
    Loop
Set myrange = Range(Cells(firstrow, 8), Cells(lastrow, 8))

Cells(outrow, 10) = Cells(lastrow, 1)
Cells(outrow, 11) = Application.WorksheetFunction.Large(myrange, 1)
Cells(outrow, 12) = Application.WorksheetFunction.Large(myrange, 2)

firstrow = lastrow + 1
outrow = outrow + 1
Loop

End Sub


20-10-10 sort 2.xlsm
ABCDEFGHIJKL
1Member SSNAccountMember IDFirst NameLast NameDOBFrom DateThru DateSSN1st Date2nd Date
2123434697Active123ParisFrance1/1/19912/1/20192/28/201912343469712/31/1910/20/19
3123434697Active123ParisFrance1/1/19913/1/20198/1/201947890876512/15/2011/12/20
4123434697Active123ParisFrance1/1/19918/1/201912/31/201990823908912/31/2011/25/20
5123434697Active123ParisFrance1/1/19912/1/20192/28/20198909234512/31/209/30/20
6123434697Active123ParisFrance1/1/19913/1/201910/1/2019
7123434697Active123ParisFrance1/1/19918/1/201910/20/2019
8478908765Active987BudLight3/23/196511/1/202012/15/2020
9478908765Active987BudLight3/23/19656/1/201910/30/2020
10478908765Active987BudLight3/23/19655/1/202011/12/2020
11478908765Active987BudLight3/23/19656/1/20197/30/2020
12908239089Active8765CoronaVirisu7/23/19569/1/20209/30/2020
13908239089Active8765CoronaVirisu7/23/195610/1/202011/25/2020
14908239089Active8765CoronaVirisu7/23/19569/1/202010/15/2020
15908239089Active8765CoronaVirisu7/23/195610/1/202012/31/2020
1689092345Active3454ZenVu4/15/198010/1/202012/31/2020
1789092345Active3454ZenVu4/15/19801/1/20199/30/2020
Date Sort
 
Upvote 0
I was really wanting a formula, I’m not sure how to use VBA. It’s awesome work though because the conditions are providing the results I need @Ezguy4u but do you have a function/formula you recommend?
 
Upvote 0
Ok so the good news is you approve of the input and the output, based on the above example. Now that means that other excel experts will be looking at this and maybe they can also come up with a function\formula solution. So let's give this some time and see what happens. I am going to see if I can come up with a function\formula, but one of the biggest problems is separating the SSN using a function\formula.
 
Upvote 0
How about
+Fluff v2.xlsm
ABCDEFGHIJK
1Member SSNAccountMember IDFirst NameLast NameDOBFrom DateThru Date
2123434697Active123ParisFrance01/01/199101/02/201928/02/20196
3123434697Active123ParisFrance01/01/199101/03/201901/08/20195
4123434697Active123ParisFrance01/01/199101/08/201901/12/20194
5123434697Active123ParisFrance01/01/199101/08/201910/12/20193
6123434697Active123ParisFrance01/01/199101/08/201931/12/20191
7123434697Active123ParisFrance01/01/199101/08/201931/12/20191
8478908765Active987BudLight23/03/196501/11/202031/12/20193
9478908765Active987BudLight23/03/196501/11/202010/10/20194
10478908765Active987BudLight23/03/196501/11/202001/05/20202
11478908765Active987BudLight23/03/196501/11/202001/08/20201
12908239089Active8765CoronaVirisu23/07/195601/09/202030/09/20202
13908239089Active8765CoronaVirisu23/07/195601/10/202031/12/20391
1489092345Active3454ZenVu15/04/198001/10/202031/12/20391
1589092345Active3454ZenVu15/04/198001/01/201930/09/20202
Data
Cell Formulas
RangeFormula
K2:K15K2=COUNTIFS(C:C,C2,J:J,">"&J2)+1
 
Upvote 0
@Ezguy4u your example is exactly what I need! So I will be patient to see if other excel experts can formulate it.
@Fluff this is good! I believe I can use this, can we also do it for column I? Because both dates From/Thru are important.
Thank you guys! Your skills are extraordinary
 
Upvote 0
Can you post some sample data along with the expected results.
 
Upvote 0
@Fluff I think I figured it out! I added to the countifs and using the =SUMPRODUCT((($C$2:$C$15=C2)*($J$2:$J$15<J2))/(COUNTIFS($J$2:$J$2:$J$15,$C$2:$C$15,C2)+($C$2:$C$15<>C2)))+1

I wish I could run this in a Macro, lol. Thanks guys
 
Upvote 0

Forum statistics

Threads
1,215,516
Messages
6,125,280
Members
449,220
Latest member
Excel Master

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