TEXTSPLIT and SORT

nburaq

Board Regular
Joined
Apr 2, 2021
Messages
222
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
Hi Gents,
I have combined intervals with "/" and I would like to split them in an ascending order is it possible to do that?
A2 B2 C2 D2 E2 F2 G2 H2 I2
4 Weeks / 6 Weeks / 12 Weeks / 6 Months / 1 Year / 2 Years / 3 Months / 3 Years4 Weeks6 Weeks12 Weeks6 Months1 Year2 Years3 Months3 Years

I can split the text with Textsplit function but when I use the Sort Function it doesnt sort like 4 Weeks 6 Weeks 12 Weeks 3 Months 6 Months 1 Year 2 Years 3 Years. Maybe I can convert to splitted text to days for each column and then sort again?

Already Thanks for all comments and help
 

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
Book1
ABCDEFGHI
14 Weeks / 6 Weeks / 12 Weeks / 6 Months / 1 Year / 2 Years / 3 Months / 3 Years4 Weeks6 Weeks12 Weeks3 Months6 Months1 Year2 Years3 Years
Sheet3
Cell Formulas
RangeFormula
B1:I1B1=LET(x,TEXTSPLIT(A1," / "),SORTBY(x,FIND(LEFT(TEXTAFTER(x," ")),"WMY"),,--TEXTBEFORE(x," "),))
Dynamic array formulas.
 
Upvote 1
Solution
Book1
ABCDEFGHI
14 Weeks / 6 Weeks / 12 Weeks / 6 Months / 1 Year / 2 Years / 3 Months / 3 Years4 Weeks6 Weeks12 Weeks3 Months6 Months1 Year2 Years3 Years
Sheet3
Cell Formulas
RangeFormula
B1:I1B1=LET(x,TEXTSPLIT(A1," / "),SORTBY(x,FIND(LEFT(TEXTAFTER(x," ")),"WMY"),,--TEXTBEFORE(x," "),))
Dynamic array formulas.
Hi,
Thanks for the solution it works great and what a brilliant idea!
 
Upvote 0
Book1
ABCDEFGHI
14 Weeks / 6 Weeks / 12 Weeks / 6 Months / 1 Year / 2 Years / 3 Months / 3 Years4 Weeks6 Weeks12 Weeks3 Months6 Months1 Year2 Years3 Years
Sheet3
Cell Formulas
RangeFormula
B1:I1B1=LET(x,TEXTSPLIT(A1," / "),SORTBY(x,FIND(LEFT(TEXTAFTER(x," ")),"WMY"),,--TEXTBEFORE(x," "),))
Dynamic array formulas.
One thing regarding this formula if a cell does not include weeks then it sorts starting from year. how can this be fixed?
 
Upvote 0
One thing regarding this formula if a cell does not include weeks then it sorts starting from year. how can this be fixed?
I can't replicate that issue:

Book1
ABCDEF
16 Months / 1 Year / 2 Years / 3 Months / 3 Years3 Months6 Months1 Year2 Years3 Years
Sheet3
Cell Formulas
RangeFormula
B1:F1B1=LET(x,TEXTSPLIT(A1," / "),SORTBY(x,FIND(LEFT(TEXTAFTER(x," ")),"WMY"),,--TEXTBEFORE(x," "),))
Dynamic array formulas.
 
Upvote 0
I go such a long way around sometimes, below is what i was playing about with - seems rather long winded but i wanted to sort by the {Week, Month, Year} and then by the number itself.
Book1
ABCDEFGHI
1
24 Weeks / 6 Weeks / 12 Weeks / 6 Months / 1 Year / 2 Years / 3 Months / 3 Years4 Weeks6 Weeks12 Weeks3 Months6 Months1 Year2 Years3 Years
3
Sheet1
Cell Formulas
RangeFormula
B2:I2B2=TOROW(LET(mp,WRAPROWS(TEXTSPLIT(SUBSTITUTE(A2," /","")," "),2),nm,--INDEX(mp,,1),wd,INDEX(mp,,2),words,MAP(LEFT(INDEX(mp,,2),1),LAMBDA(x,MATCH(x,{"W","M","Y"},0))),BYROW(TAKE(SORT(HSTACK(nm,wd,words),{3,1},{1,1}),,2),LAMBDA(x,TEXTJOIN(" ",,x)))))
Dynamic array formulas.
 
Upvote 1
I go such a long way around sometimes, below is what i was playing about with - seems rather long winded but i wanted to sort by the {Week, Month, Year} and then by the number itself.
Book1
ABCDEFGHI
1
24 Weeks / 6 Weeks / 12 Weeks / 6 Months / 1 Year / 2 Years / 3 Months / 3 Years4 Weeks6 Weeks12 Weeks3 Months6 Months1 Year2 Years3 Years
3
Sheet1
Cell Formulas
RangeFormula
B2:I2B2=TOROW(LET(mp,WRAPROWS(TEXTSPLIT(SUBSTITUTE(A2," /","")," "),2),nm,--INDEX(mp,,1),wd,INDEX(mp,,2),words,MAP(LEFT(INDEX(mp,,2),1),LAMBDA(x,MATCH(x,{"W","M","Y"},0))),BYROW(TAKE(SORT(HSTACK(nm,wd,words),{3,1},{1,1}),,2),LAMBDA(x,TEXTJOIN(" ",,x)))))
Dynamic array formulas.
This one works perfect! I will not ask how because seems very complicated to me :) Thanks again for your help!!!
 
Upvote 0

Forum statistics

Threads
1,215,493
Messages
6,125,128
Members
449,206
Latest member
burgsrus

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