Concatenate/TextJoin using a different delimiter between 2nd Last and Last entry (Excel or Sheets)

Jaypee666

New Member
Joined
May 26, 2020
Messages
26
Office Version
  1. 365
  2. 2016
  3. 2010
Platform
  1. Windows
Hi all,
Not sure if what I'm looking to do is possible or not.
I have 2 columns M & N that populate based on another columns content.
I then have 2 cells that do a TextJoin on the relevant column, J15 does a TextJoin for Column M & J17 for N
What I'm wondering is, Is itpossible to Concatentate/TextJoin using a different delimiter between 2nd Last and Last entry in either Excel or Google Sheets.

So in the sample provided below is it possible to have J15 return Area 1, Area 2 & Area 3 and J7 to return Area 4 & Area 5

Board-Sample.xlsx
JKLMN
13NOTESHighModerate
14HIGH  
15Area 1, Area 2, Area 3,Area 1, 
16MODERATE  
17Area 4, Area 5,Area 2, 
18  
19Area 3, 
20  
21 Area 4,
22  
23 Area 5,
24  
25  
Report-1
Cell Formulas
RangeFormula
M14,M16,M18,M20,M22,M24M14=IFNA(IF(G14="HIGH",CONCATENATE("Area ", A14,","), ""),"")
N14,N16,N18,N20,N22,N24N14=IFNA(IF(G14="MODERATE",CONCATENATE("Area ", A14,","), ""),"")
M15,M17,M19,M21,M23,M25M15=IFNA(IF(G15="HIGH",CONCATENATE("Area ", A14,","), ""),"")
N15,N17,N19,N21,N23,N25N15=IFNA(IF(G15="MODERATE",CONCATENATE("Area ", A14,","), ""),"")
J15J15=TEXTJOIN(" ", TRUE, M14:M53)
J17J17=TEXTJOIN(" ", TRUE, N14:N53)
Cells with Conditional Formatting
CellConditionCell FormatStop If True
M14:N73Expression=AND(COUNTIF($M$14:$N$43,M14)>1,$N14<>"")textNO



Thanks for looking
 
Glad we could help & thanks for the feedback.
 
Upvote 0

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
I know you have a solution that works for you ...

... but if you wanted to, you could dispense with your helper formulae:

ABCDEFGHIJ
13NOTES
141HIGH
15HighArea 1, Area 2 & Area 3
162MODERATE
17HighArea 4 & Area 5
183LOW
19High-
204
21Moderate
225
23Moderate
24
Sheet1
Cell Formulas
RangeFormula
J15,J19,J17J15=LET(d,"Area "&FILTER($A$14:$A$22,$G$15:$G$23=J14),n,ROWS(d),t,TEXTJOIN(", ",1,d),IFERROR(IF(n<2,t,SUBSTITUTE(t,","," &",n-1)),"-"))
 
Upvote 0
Hi Fluff,

I am only getting around to properly implementing this on my worksheet, and I noticed that if there is only 1 entry in the range it returns a #Value error. I know from running through the evaluation it has something to do with the "-LEN" section of the string, but for the life of me I can't figure out how to over come it so that if there is only 1 Value, it simply returns that value.
I know this is probably something simply when you know what you're doing :)

Sample below

Cell Formulas
RangeFormula
M14,M16,M18,M20,M22,M24,M26,M28,M30,M32,M34M14=IFNA(IF(G14="HIGH",CONCATENATE("Area ", A14,","), ""),"")
N14,N16,N18,N20,N22,N24,N26,N28,N30,N32,N34N14=IFNA(IF(G14="MODERATE",CONCATENATE("Area ", A14,","), ""),"")
M15,M17,M19,M21,M23,M25,M27,M29,M31,M33,M35M15=IFNA(IF(G15="HIGH",CONCATENATE("Area ", A14,","), ""),"")
N15,N17,N19,N21,N23,N25,N27,N29,N31,N33,N35N15=IFNA(IF(G15="MODERATE",CONCATENATE("Area ", A14,","), ""),"")
J15J15=IFERROR(SUBSTITUTE(TEXTJOIN(", ",,SUBSTITUTE(M14:M55,",","")),", "," & ",LEN(TEXTJOIN(", ",,SUBSTITUTE(M14:M55,",","")))-LEN(SUBSTITUTE(TEXTJOIN(", ",,SUBSTITUTE(M14:M55,",","")),",",""))),"No Areas to Action")
J17J17=IFERROR(SUBSTITUTE(TEXTJOIN(", ",,SUBSTITUTE(N14:N56,",","")),", "," & ",LEN(TEXTJOIN(", ",,SUBSTITUTE(N14:N56,",","")))-LEN(SUBSTITUTE(TEXTJOIN(", ",,SUBSTITUTE(N14:N56,",","")),",",""))),"No Areas to Action")



Thanks in advance for all your help on this.
 
Last edited by a moderator:
Upvote 0
Since this old thread has been revived anyway, I wondered if it possible that column M and/or N could have only 1 or zero actual values?
If so the accepted answer would return an error as shown in J17 below.
Alternative suggested just in case it is useful to OP or other readers.

23 02 24.xlsm
JKLMN
13NOTESHighModerate
14HIGH
15Area 1, Area 2 & Area 3Area 1,
16MODERATE
17#VALUE!Area 2,
18Area 4
19Area 3,
20
21Area 4,
22
23
TEXTJOIN
Cell Formulas
RangeFormula
J15J15=LET(t,TEXTJOIN(", ",,SUBSTITUTE(M14:M53,",","")),IF(ISNUMBER(FIND(",",t)),SUBSTITUTE(t,", "," & ",LEN(t)-LEN(SUBSTITUTE(t,",",""))),t))
J17J17=LET(t,TEXTJOIN(", ",,SUBSTITUTE(N14:N53,",","")),SUBSTITUTE(t,", "," & ",LEN(t)-LEN(SUBSTITUTE(t,",",""))))
J18J18=LET(t,TEXTJOIN(", ",,SUBSTITUTE(N14:N53,",","")),IF(ISNUMBER(FIND(",",t)),SUBSTITUTE(t,", "," & ",LEN(t)-LEN(SUBSTITUTE(t,",",""))),t))
 
Upvote 1
Thank you
Since this old thread has been revived anyway, I wondered if it possible that column M and/or N could have only 1 or zero actual values?
If so the accepted answer would return an error as shown in J17 below.
Alternative suggested just in case it is useful to OP or other readers.

23 02 24.xlsm
JKLMN
13NOTESHighModerate
14HIGH
15Area 1, Area 2 & Area 3Area 1,
16MODERATE
17#VALUE!Area 2,
18Area 4
19Area 3,
20
21Area 4,
22
23
TEXTJOIN
Cell Formulas
RangeFormula
J15J15=LET(t,TEXTJOIN(", ",,SUBSTITUTE(M14:M53,",","")),IF(ISNUMBER(FIND(",",t)),SUBSTITUTE(t,", "," & ",LEN(t)-LEN(SUBSTITUTE(t,",",""))),t))
J17J17=LET(t,TEXTJOIN(", ",,SUBSTITUTE(N14:N53,",","")),SUBSTITUTE(t,", "," & ",LEN(t)-LEN(SUBSTITUTE(t,",",""))))
J18J18=LET(t,TEXTJOIN(", ",,SUBSTITUTE(N14:N53,",","")),IF(ISNUMBER(FIND(",",t)),SUBSTITUTE(t,", "," & ",LEN(t)-LEN(SUBSTITUTE(t,",",""))),t))
Thank you, your J18 solution is exacty what I needed. :)
 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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