# Ranking dates based off year to create unique transaction #

#### dlmoore99

##### Board Regular
New twist to previous answered thread. I'm now trying to figure out how to rank entries based off name and date. So if the same name appears more than once in one column and same the date in another column matches, create a duplicate unique id, if not continue the unique ID numbering.

Book1.xlsx
ABCD
1CustomerTransaction DateCurrent FormulaWhat it should look like
2Bob S12/15/172017-022017-02
3Bob S12/12/172017-012017-01
4Joe D12/19/172017-032017-03
5Carl C12/27/172017-042017-04
6Andy L02/09/182018-022018-02
7Will T01/15/182018-012018-01
8Tom G03/22/182018-032018-03
9Joe D03/23/182018-042018-04
10Joe D03/23/182018-052018-04
11Bob S03/31/182018-062018-05
12Fred G09/17/182018-072018-06
13Al M10/28/182018-082018-07
14Scott F11/03/182018-092018-08
15Mark W01/19/192019-012019-01
16Brett B02/07/192019-022019-02
17Marcus J08/15/192019-032019-03
18Robert M10/04/192019-042019-04
19Charles H03/13/202020-012020-01
20Charles H03/13/202020-022020-01
Sheet1
Cell Formulas
RangeFormula
C2:C20C2=TEXT(B2,"yyyy-")&TEXT(SUMPRODUCT(--(YEAR(\$B\$2:\$B\$20)=YEAR(B2)),--(\$B\$2:\$B\$20<B2))+COUNTIFS(B\$2:B2,B2),"00")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B20,D2:D20Cellcontains a blank value textNO

### Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.

#### Peter_SSs

##### MrExcel MVP, Moderator
Try this. In your version it may need confirming with Ctrl+Shift+Enter, not just Enter.

21 03 13.xlsm
BCD
1Transaction DateCurrent FormulaWhat it should look like
215/12/20172017-022017-02
312/12/20172017-012017-01
419/12/20172017-032017-03
527/12/20172017-042017-04
69/02/20182018-022018-02
715/01/20182018-012018-01
822/03/20182018-032018-03
923/03/20182018-042018-04
1023/03/20182018-052018-04
1131/03/20182018-062018-05
1217/09/20182018-072018-06
1328/10/20182018-082018-07
143/11/20182018-092018-08
1519/01/20192019-012019-01
167/02/20192019-022019-02
1715/08/20192019-032019-03
184/10/20192019-042019-04
1913/03/20202020-012020-01
2013/03/20202020-022020-01
Trans #
Cell Formulas
RangeFormula
C2:C20C2=TEXT(B2,"yyyy-")&TEXT(SUMPRODUCT(--(YEAR(\$B\$2:\$B\$20)=YEAR(B2)),--(\$B\$2:\$B\$20<B2))+COUNTIFS(B\$2:B2,B2),"00")
D2:D20D2=TEXT(B2,"yyyy-")&TEXT(SUMPRODUCT(--(YEAR(\$B\$2:\$B\$20)=YEAR(B2)),--(\$B\$2:\$B\$20<B2),--(ROW(\$B\$2:\$B\$20)-ROW(\$B\$2)+1=MATCH(\$B\$2:\$B\$20,\$B\$2:\$B\$20,0)))+1,"00")

#### dlmoore99

##### Board Regular
Try this. In your version it may need confirming with Ctrl+Shift+Enter, not just Enter.

21 03 13.xlsm
BCD
1Transaction DateCurrent FormulaWhat it should look like
215/12/20172017-022017-02
312/12/20172017-012017-01
419/12/20172017-032017-03
527/12/20172017-042017-04
69/02/20182018-022018-02
715/01/20182018-012018-01
822/03/20182018-032018-03
923/03/20182018-042018-04
1023/03/20182018-052018-04
1131/03/20182018-062018-05
1217/09/20182018-072018-06
1328/10/20182018-082018-07
143/11/20182018-092018-08
1519/01/20192019-012019-01
167/02/20192019-022019-02
1715/08/20192019-032019-03
184/10/20192019-042019-04
1913/03/20202020-012020-01
2013/03/20202020-022020-01
Trans #
Cell Formulas
RangeFormula
C2:C20C2=TEXT(B2,"yyyy-")&TEXT(SUMPRODUCT(--(YEAR(\$B\$2:\$B\$20)=YEAR(B2)),--(\$B\$2:\$B\$20<B2))+COUNTIFS(B\$2:B2,B2),"00")
D2:D20D2=TEXT(B2,"yyyy-")&TEXT(SUMPRODUCT(--(YEAR(\$B\$2:\$B\$20)=YEAR(B2)),--(\$B\$2:\$B\$20<B2),--(ROW(\$B\$2:\$B\$20)-ROW(\$B\$2)+1=MATCH(\$B\$2:\$B\$20,\$B\$2:\$B\$20,0)))+1,"00")
That won't work if I have a different customer transaction on the same day.
Book1.xlsx
ABCD
1CustomerTransaction DateCurrent FormulaWhat it should look like
2Bob S12/15/172017-022017-02
3Bob S12/12/172017-012017-01
4Joe D12/19/172017-032017-03
5Carl C12/27/172017-042017-04
6Andy L02/09/182018-022018-02
7Will T01/15/182018-012018-01
8Tom G03/22/182018-032018-03
9Joe D03/23/182018-042018-04
10Joe D03/23/182018-042018-04
11Bob S03/23/182018-042018-05
12Fred G09/17/182018-052018-06
13Al M10/28/182018-062018-07
14Scott F11/03/182018-072018-08
15Mark W01/19/192019-012019-01
16Brett B02/07/192019-022019-02
17Marcus J08/15/192019-032019-03
18Robert M10/04/192019-042019-04
19Charles H03/13/202020-012020-01
20Charles H03/13/202020-012020-01
Sheet1
Cell Formulas
RangeFormula
C2:C20C2=TEXT(B2,"yyyy-")&TEXT(SUMPRODUCT(--(YEAR(\$B\$2:\$B\$20)=YEAR(B2)),--(\$B\$2:\$B\$20<B2),--(ROW(\$B\$2:\$B\$20)-ROW(\$B\$2)+1=MATCH(\$B\$2:\$B\$20,\$B\$2:\$B\$20,0)))+1,"00")
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B20,D2:D20Cellcontains a blank value textNO

#### kvsrinivasamurthy

##### Well-known Member
This ARRAY formula in C2 then copied down also works.

=TEXT(B2,"yyyy-")&TEXT(1+SUM(IFERROR(1/((YEAR(\$B\$2:\$B\$20)=YEAR(B2))*COUNTIFS(B2,">"&B\$2:\$B\$20)*COUNTIFS(B\$2:\$B\$20,B\$2:\$B\$20)),0)),"00")

To enter ARRAY formula
Copy and paste the formula in cell
Press F2
Press Ctrl+Shift+Enter together
Excel covers the formula with {}.

#### dlmoore99

##### Board Regular

This ARRAY formula in C2 then copied down also works.

=TEXT(B2,"yyyy-")&TEXT(1+SUM(IFERROR(1/((YEAR(\$B\$2:\$B\$20)=YEAR(B2))*COUNTIFS(B2,">"&B\$2:\$B\$20)*COUNTIFS(B\$2:\$B\$20,B\$2:\$B\$20)),0)),"00")

To enter ARRAY formula
Copy and paste the formula in cell
Press F2
Press Ctrl+Shift+Enter together
Excel covers the formula with {}.
I still get the same issue, when there is a transaction on the same date, it counts all transactions as the same and get the same ID # and doesn't account for a different name when on the same date. So I need the transaction to account for the name as well as the date and not just date.

#### Marcelo Branco

##### MrExcel MVP
Maybe...

Pasta1
ABC
1CustomerTransaction DateFormula
2Bob S12/15/20172017-02
3Bob S12/12/20172017-01
4Joe D12/19/20172017-03
5Carl C12/27/20172017-04
6Andy L02/09/20182018-02
7Will T01/15/20182018-01
8Tom G03/22/20182018-03
9Joe D03/23/20182018-05
10Joe D03/23/20182018-05
11Bob S03/23/20182018-04
12Fred G09/17/20182018-06
13Al M10/28/20182018-07
14Scott F11/03/20182018-08
15Mark W01/19/20192019-01
16Brett B02/07/20192019-02
17Marcus J08/15/20192019-03
18Robert M10/04/20192019-04
19Charles H03/13/20202020-01
20Charles H03/13/20202020-01
Planilha5
Cell Formulas
RangeFormula
C2:C20C2=TEXT(B2,"aaaa")&"-"&TEXT(SUMPRODUCT(--(YEAR(B\$2:B\$20)=YEAR(B2)),--(B\$2:B\$20&A\$2:A\$20<B2&A2),--(MATCH(A\$2:A\$20&B\$2:B\$20,A\$2:A\$20&B\$2:B\$20,0)=ROW(B\$2:B\$20)-ROW(B\$2)+1))+1,"00")

Note that on 03/23/2018 Bob S received a lower ranking than Joe D, because, alphabetically, Bob is lower than Joe.

M.

#### dlmoore99

##### Board Regular

Maybe...

Pasta1
ABC
1CustomerTransaction DateFormula
2Bob S12/15/20172017-02
3Bob S12/12/20172017-01
4Joe D12/19/20172017-03
5Carl C12/27/20172017-04
6Andy L02/09/20182018-02
7Will T01/15/20182018-01
8Tom G03/22/20182018-03
9Joe D03/23/20182018-05
10Joe D03/23/20182018-05
11Bob S03/23/20182018-04
12Fred G09/17/20182018-06
13Al M10/28/20182018-07
14Scott F11/03/20182018-08
15Mark W01/19/20192019-01
16Brett B02/07/20192019-02
17Marcus J08/15/20192019-03
18Robert M10/04/20192019-04
19Charles H03/13/20202020-01
20Charles H03/13/20202020-01
Planilha5
Cell Formulas
RangeFormula
C2:C20C2=TEXT(B2,"aaaa")&"-"&TEXT(SUMPRODUCT(--(YEAR(B\$2:B\$20)=YEAR(B2)),--(B\$2:B\$20&A\$2:A\$20<B2&A2),--(MATCH(A\$2:A\$20&B\$2:B\$20,A\$2:A\$20&B\$2:B\$20,0)=ROW(B\$2:B\$20)-ROW(B\$2)+1))+1,"00")

Note that on 03/23/2018 Bob S received a lower ranking than Joe D, because, alphabetically, Bob is lower than Joe.

M.
Marcelo, thanks for that formula, works great. Is there any way to make it say "Exempt" for the Transaction ID if there is a certain name in the list and it will skip numbering that cell and continue numbering in the next cell?

#### Marcelo Branco

##### MrExcel MVP
Marcelo, thanks for that formula, works great. Is there any way to make it say "Exempt" for the Transaction ID if there is a certain name in the list and it will skip numbering that cell and continue numbering in the next cell?

I didn't quite understand what you want now - maybe an example?

M.

#### dlmoore99

##### Board Regular
I didn't quite understand what you want now - maybe an example?

M.
so if the name Al was in column A then the unique ID would be "Exempt" and not get a unique Transaction # and the unique transaction numbering would skip the Exempt and go one to the next row.

Book1.xlsx
ABCD
1CustomerTransaction DateMarcelo's FormulaWhat it should look like
2Bob S12/15/172017-022017-02
3Bob S12/12/172017-012017-01
4Joe D12/19/172017-032017-03
5Carl C12/27/172017-042017-04
6Andy L02/09/182018-022018-02
7Will T01/15/182018-012018-01
8Tom G03/22/182018-032018-03
9Joe D03/23/182018-052018-05
10Joe D03/23/182018-052018-04
11Bob S03/23/182018-042018-04
12Fred G09/17/182018-062018-06
13Al M10/28/182018-07Exempt
14Scott F11/03/182018-082018-07
15Mark W01/19/192019-012019-01
16Brett B02/07/192019-022019-02
17Marcus J08/15/192019-032019-03
18Robert M10/04/192019-042019-04
19Charles H03/13/202020-022020-02
20Brett B03/13/202020-012020-01
Sheet1
Cell Formulas
RangeFormula
C2:C20C2=IF(A2="","",TEXT(B2,"yyyy-")&TEXT(SUMPRODUCT(--(YEAR(B\$2:B\$20)=YEAR(B2)),--(B\$2:B\$20&A\$2:A\$20<B2&A2),--(MATCH(A\$2:A\$20&B\$2:B\$20,A\$2:A\$20&B\$2:B\$20,0)=ROW(B\$2:B\$20)-ROW(B\$2)+1))+1,"00"))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B2:B20,D2:D20Cellcontains a blank value textNO

#### Marcelo Branco

##### MrExcel MVP
Try

=IF(A2="","",IF(A2="Al M","Exempt",TEXT(B2,"yyyyy-")&TEXT(SUMPRODUCT(--(A\$2:A\$20<>"Al M"),--(YEAR(B\$2:B\$20)=YEAR(B2)),--(B\$2:B\$20&A\$2:A\$20<B2&A2),--(MATCH(A\$2:A\$20&B\$2:B\$20,A\$2:A\$20&B\$2:B\$20,0)=ROW(B\$2:B\$20)-ROW(B\$2)+1))+1,"00")))

M.

Replies
9
Views
156
Replies
1
Views
308
Replies
5
Views
53
Replies
19
Views
399
Replies
0
Views
292

1,130,110
Messages
5,640,147
Members
417,127
Latest member
shakilk

### 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.

### Which adblocker are you using?

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

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