Finding the Unique value, and then find the corresponding year

Goddess

Board Regular
Joined
Dec 3, 2015
Messages
120
Office Version
  1. 2021
Platform
  1. Windows
/Hi,

I have a table with various text and a date corresponding to the text. I need to find the unique value in column A and then return the year. Anyone can help?

Book1
ABCDEF
1DataResult
2Apple5 Nov 2014Apple2014
3Grape10 Nov 20142017
4Apple20 Nov 20142018
5Orange15 Dec 2014Grape2014
6Apple10 Aug 20172018
7Apple20 Sept 2017Orange2014
8Orange20 Sept 20172017
9Grape15 Jan 20182018
10Grape15 Jan 2018
11Orange05 Feb 2018
12Orange05 Feb 2018
13Apple5 Feb 2018
14
Sheet1


Thanks!
 
Using formulas you would not be able to have those merged cells. Would this suffice or do you need a vba solution?

25 03 28.xlsm
ABCDE
1Data
2Apple5 Nov 2014Apple2014
3Grape10 Nov 2014Apple2017
4Apple20 Nov 2014Apple2018
5Orange15 Dec 2014Grape2014
6Apple10 Aug 2017Grape2018
7Apple20 Sep 2017Orange2014
8Orange20 Sep 2017Orange2017
9Grape15 Jan 2018Orange2018
10Grape15 Jan 2018
11Orange5 Feb 2018
12Orange5 Feb 2018
13Apple5 Feb 2018
Goddess
Cell Formulas
RangeFormula
D2:D9D2=LET(a,A2:A13,y,YEAR(B2:B13),x,UNIQUE(SORTBY(a&"|"&y,a)),LEFT(x,FIND("|",x)-1))
E2:E9E2=LET(a,A2:A13,y,YEAR(B2:B13),x,UNIQUE(SORTBY(a&"|"&y,a)),REPLACE(x,1,FIND("|",x),""))
Dynamic array formulas.
 
Upvote 0
A bit shorter :

In D2 : =SORT(TEXTBEFORE(UNIQUE(A2:A13 & YEAR(B2:B13)),2))

In E2 : =RIGHT(SORT(UNIQUE(A2:A13&YEAR(B2:B13))),4)
 
Upvote 0
Can do only in D2 : =LET(a,UNIQUE(A2:A13&YEAR(B2:B13)),HSTACK(SORT(TEXTBEFORE(a,2)),RIGHT(SORT(a),4)))
 
Upvote 0
Thanks both for the super prompt replies! Appreciate it as always...

@Peter : Will try and see if I can work without merging the cells. No VBA for me as I'm already not very good in Excel, VBA will kill me 😂
 
Upvote 0
A bit shorter :

=LET(a,SORT(UNIQUE(A2:A13&YEAR(B2:B13))),HSTACK(TEXTBEFORE(a,2),RIGHT(a,4)))
 
Upvote 0

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