# Ranking dates based off year to create unique transaction #

#### dlmoore99

##### Board Regular
Hello community, I've been racking my brain for a while now and need help. I'm trying to create unique transaction #'s based of the transaction date. Issue is that I need to start the transaction date over every year. I'm using Rank and Countifs functions combined to help create the Transaction ID but can't figure out how to start the numbering over for each year. Any help would be greatly appreciated.

Book1.xlsx
ABCD
1Transaction DateID # w/duplicatesID # w/o duplicatesWhat it should look like
212/15/172017-022017-022017-02
312/12/172017-012017-012017-01
412/19/172017-032017-032017-03
512/27/172017-042017-042017-04
602/09/182018-062018-062018-02
701/15/182018-052018-052018-01
803/22/182018-072018-072018-03
903/23/182018-082018-082018-04
1003/23/182018-082018-092018-05
1103/31/182018-0102018-0102018-06
1209/17/182018-0112018-0112018-07
1310/28/182018-0122018-0122018-08
1411/03/182018-0132018-0132018-09
1501/19/192019-0142019-0142019-01
1602/07/192019-0152019-0152019-02
1708/15/192019-0162019-0162019-03
1810/04/192019-0172019-0172019-04
1903/13/202020-0182020-0182020-01
2003/13/202020-0182020-0192020-02
21
Sheet1
Cell Formulas
RangeFormula
B2:B20B2=TEXT(A:A,"yyyy")&"-0"&RANK(A2,A\$2:A\$20,1)
C2:C20C2=TEXT(A:A,"yyyy")&"-0"&RANK(A2,A\$2:A\$1000,1)+COUNTIF(\$A\$2:A2,A2)-1
Cells with Conditional Formatting
CellConditionCell FormatStop If True
A2:A20,D2:D20Cellcontains a blank value textNO

### Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

#### Fluff

##### MrExcel MVP, Moderator
What version of Excel are you using?

I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

#### dlmoore99

##### Board Regular
Sorry, info is updated

#### Fluff

##### MrExcel MVP, Moderator
Thanks for that, how about
+Fluff 1.xlsm
AC
1Transaction DateID # w/o duplicates
215/12/20172017-02
312/12/20172017-01
419/12/20172017-03
527/12/20172017-04
609/02/20182018-02
715/01/20182018-01
822/03/20182018-03
923/03/20182018-04
1023/03/20182018-05
1131/03/20182018-06
1217/09/20182018-07
1328/10/20182018-08
1403/11/20182018-09
1519/01/20192019-01
1607/02/20192019-02
1715/08/20192019-03
1804/10/20192019-04
1913/03/20202020-01
2013/03/20202020-02
21
Main
Cell Formulas
RangeFormula
C2:C20C2=TEXT(A2,"yyyy-")&TEXT(MATCH(A2,AGGREGATE(15,6,\$A\$2:\$A\$100/(YEAR(\$A\$2:\$A\$100)=YEAR(A2)),ROW(\$A\$2:\$A\$100)-ROW(A\$2)+1),0)+COUNTIFS(A\$2:A2,A2)-1,"00")

#### dlmoore99

##### Board Regular

ADVERTISEMENT

Fluff, when I paste your formula into my spreadsheet, the cell returns #N/A, cell format in column C is General

#### Marcelo Branco

##### MrExcel MVP
Maybe...

D2 copied down
=TEXT(A2,"yyyy")&"-"&TEXT(SUMPRODUCT(--(YEAR(\$A\$2:\$A\$20)=YEAR(A2)),--(\$A\$2:\$A\$20<A2))+COUNTIFS(A\$2:A2,A2),"00")

M.

#### Marcelo Branco

##### MrExcel MVP

ADVERTISEMENT

Test

Pasta1
AB
1Transaction DateID# w/o duplicates
212/15/20172017-02
312/12/20172017-01
412/19/20172017-03
512/27/20172017-04
602/09/20182018-02
701/15/20182018-01
803/22/20182018-03
903/23/20182018-04
1003/23/20182018-05
1103/31/20182018-06
1209/17/20182018-07
1310/28/20182018-08
1411/03/20182018-09
1501/19/20192019-01
1602/07/20192019-02
1708/15/20192019-03
1810/04/20192019-04
1903/13/20202020-01
2003/13/20202020-02
dlmoore
Cell Formulas
RangeFormula
B2:B20B2=TEXT(A2,"aaaa")&"-"&TEXT(SUMPRODUCT(--(YEAR(\$A\$2:\$A\$20)=YEAR(A2)),--(\$A\$2:\$A\$20<A2))+COUNTIFS(A\$2:A2,A2),"00")

Replace "aaaa" by "yyyy" in the formulas ("aaaa" = Portuguese)

Hope this helps

M.

#### dlmoore99

##### Board Regular
Marcelo, that formula worked, Thanks to both you and Fluff for your time and knowledge.

#### Fluff

##### MrExcel MVP, Moderator
Glad we could help & thanks for the feedback.

#### Marcelo Branco

##### MrExcel MVP
Marcelo, that formula worked, Thanks to both you and Fluff for your time and knowledge.
You are welcome. Glad to help.

M.

Replies
20
Views
343
Replies
11
Views
228
Replies
1
Views
303
Replies
0
Views
134
Replies
3
Views
60

Threads
1,129,684
Messages
5,637,790
Members
416,982
Latest member
lisam77

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

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