TEXTJOIN/ CONCATENATE with numbering and formatting

Shark88

New Member
Joined
Jul 5, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
I’m trying to combine a series of cells but want it in a list format, so for example if the cells are:
A1 Apple
A2 01/01/2024
A3 Banana
A4 02/01/2024
A5
A6

I want it to read:

1. Apple 01/01/2024
2. Banana 02/01/2024

I’m currently using

TEXTJOIN(“”,TRUE, “1.”,A1,TEXT(A2, “mm/dd/yyyy”),CHAR(10), “2.”,A3,TEXT(A4, mm/dd/yyyy”),CHAR(10), “3.”, A5, TEXT(A6, mm/dd/yyy”))

The problem is that each column has varying numbers of fields to combine so I want it to essentially stop adding the numbering and empty date showing up as 01/00/1900.

If I remove the text for the date formatting, regardless of how the information is stored it keeps trying to return it as a number and I have not found another way of fixing that. I can’t seem to find another way to add a number in front to create steps in a list either, but I end up having the following returned:

1. Apple 01/01/2024
2. Banana 02/01/2024
3. 01/00/1900
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
Not at all sure that I have what you want here,

MrExcelPlayground23.xlsx
ABC
1Apple1. Apple 01/01/2024
21/1/20242. Banana 02/01/2024
3Banana
42/1/2024
5
6
7
8
9
10
Sheet10
Cell Formulas
RangeFormula
C1:C2C1=LET(a,A1:A10,b,INDEX(a,SEQUENCE(ROWS(a)/2,2)),c,FILTER(b,CHOOSECOLS(b,2)>0),d,ROWS(c),e,HSTACK(SEQUENCE(d),c),f,BYROW(e,LAMBDA(a,INDEX(a,,1)&". "&INDEX(a,,2)&" "&TEXT(INDEX(a,,3),"mm/dd/yyy"))),f)
Dynamic array formulas.
 
Upvote 0
Last edited:
Upvote 0
A little shorter.
Excel Formula:
=LET(
x,WRAPROWS(TOCOL(A1:A14,1),2),
TEXTJOIN(CHAR(10),,SEQUENCE(ROWS(x)) &". "& INDEX(x,,1) & " " & TEXT(INDEX(x,,2),"mm/dd/yyyy")))
 
Upvote 0
Standard (no LET so shall work also with Excel 2019 and 2021) formula:
Excel Formula:
=TEXTJOIN("",TRUE,IF(A1:A16="","",IF(ISODD(ROW(A1:A16)),(ROW(A1:A16)+1)/2 & ". " & A1:A16,TEXT(A1:A16," mm/dd/yyyy") & CHAR(10))))

Remember to set cell formatting as wrapping text and wide enough to fit description and date.

note empty first argument ("") and space in front of date formatting string "_mm/dd/yyyy"
 
Upvote 0
A little shorter.
Excel Formula:
=LET(
x,WRAPROWS(TOCOL(A1:A14,1),2),
TEXTJOIN(CHAR(10),,SEQUENCE(ROWS(x)) &". "& INDEX(x,,1) & " " & TEXT(INDEX(x,,2),"mm/dd/yyyy")))
Here is a little bit shorter formula that will also work...
Excel Formula:
=TEXTJOIN(HSTACK(" "," ",CHAR(10)),,HSTACK(SEQUENCE(ROWS(A1:A8)/2),TEXT(WRAPROWS(A1:A8,2),"dd/mm/e")))
 
Last edited:
Upvote 0
Here is a little bit shorter formula that will also work...
Excel Formula:
=TEXTJOIN(HSTACK(" "," ",CHAR(10)),,HSTACK(SEQUENCE(ROWS(A1:A8)/2),TEXT(WRAPROWS(A1:A8,2),"dd/mm/e")))
Very interesting array behavior. I didn’t know TEXTJOIN behave like that.
 
Upvote 0
Very interesting array behavior. I didn’t know TEXTJOIN behave like that.
All the TEXTxxx functions can take an array of values as their delimiter. TEXTJOIN distributes them cyclically whereas the others treat all the arrayed delimiters as if they were the same delimiter. Here is the text from a mini article that I posted on LinkedIn about this...

Okay, I just discovered something about the TEXTJOIN function through experimentation that I was not aware of before... you can specify multiple delimiters and they will be applied in the order listed! Put some text in each of the cells of the range A1:A4 and then put this formula in another cell and look at how the delimiters are distributed between the text from the cells...

=TEXTJOIN({"-","/","="},,A1:A4)

Neat, right? Even neater is if there is more text than delimiters to separate them, the delimiters are applied cyclically. For example, put text in each of the cells of the range A1:A6 and then put this formula in another cell and look as how the two delimiters are distributed through the six text strings...

=TEXTJOIN({"-","/"},,A1:A6)

Really, really neat, right?
 
Last edited:
Upvote 0
All the TEXTxxx functions can take an array of values as their delimiter. TEXTJOIN distributes them cyclically whereas the others treat all the arrayed delimiters as if they were the same delimiter. Here is the text from a mini article that I posted on LinkedIn about this...

Okay, I just discovered something about the TEXTJOIN function through experimentation that I was not aware of before... you can specify multiple delimiters and they will be applied in the order listed! Put some text in each of the cells of the range A1:A4 and then put this formula in another cell and look at how the delimiters are distributed between the text from the cells...

=TEXTJOIN({"-","/","="},,A1:A4)

Neat, right? Even neater is if there is more text than delimiters to separate them, the delimiters are applied cyclically. For example, put text in each of the cells of the range A1:A6 and then put this formula in another cell and look as how the two delimiters are distributed through the six text strings...

=TEXTJOIN({"-","/"},,A1:A6)

Really, really neat, right?
Neat indeed. I've played around a bit and it seems like the default behavior is left to right then top down. To join top down then left right I've added TRANPOSE.
I've also noticed the format mm/dd/e what does the 'e' mean?
 
Upvote 0

Forum statistics

Threads
1,223,702
Messages
6,173,966
Members
452,539
Latest member
delvey

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