Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to apply number or date format to columns after TEXTSPLIT in Excel

I use TEXTSPLIT to cut text composed of multiple parts, like for example: the country, the date and the value:

"USA-01/01/2023-1000"

=TEXTSPLIT(A1,"-")

Unfortunately, the result is a spill formula (dynamic array) where the date and the value are "text" (which is normal after a text function). This poses a big problem if I want to SORT, because the sorting is applied as TEXT, not as date.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Is there a way to have the date and number columns recognized as number, without having to enumerate each column to apply the format?

My current solution:

For now I use let to name the textsplit part and I use choosecols for each column and multiply by 1 the number ones… before using SORT:

=LET(a,TEXTSPLIT(A1,"-"),HSTACK(CHOOSECOLS(a,1),CHOOSECOLS(a,2)*1,CHOOSECOLS(a,3)*1))

But this seems overcomplicated… especially when the equivalent SPLIT array formula in GoogleSheet applies immediately the correct dates and number format to each part.

>Solution :

You could use:

=LET(d,TEXTSPLIT(A1,"-"),IFERROR(d+0,d))

but you’ll have to manually apply any number/date formatting to the relevant cells.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading