Textjoin

Deelof

New Member
Joined
Aug 30, 2023
Messages
34
Office Version
  1. 2019
Platform
  1. Windows
Looking to use textjoin with multiple if statements to return the result in below example.
I need to identify if Width is populated to return "W 1400" or if Diameter is to return "DIA 1400"
Can anyone assist?

TEXTJOIN OUTCOMENAME#1HEIGHT (mm)WIDTH (mm)DEPTH (mm)DIAMETER (mm)SEAT HEIGHT (mm)ARM HEIGHT (mm)
HANLEY / TEAL / H 550 W 1400 D 420 SH 50 AH 100HANLEYBLUE550140042050100
HANLEY / TEAL / H 550 DIA 1400 SH 70HANLEYBLUE550140070
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
I assume TEAL should be Blue, but don't you need to check for other things like depth and arm height existing as well?
 
Upvote 0
I would just use the CONCATENATE operator:
=B2&" / "&C2&" / "&IF(D2," H " & D2,"")&IF(E2," W " & E2,"")&IF(F2," D "&F2,"")&IF(G2," DIA " & G2,"")&IF(H2," SH "&H2,"")& IF(I2," AH "&I2,"")

Book1
ABCDEFGHIJK
1TEXTJOIN OUTCOMENAME#1HEIGHT (mm)WIDTH (mm)DEPTH (mm)DIAMETER (mm)SEAT HEIGHT (mm)ARM HEIGHT (mm)RESULT
2HANLEY / TEAL / H 550 W 1400 D 420 SH 50 AH 100HANLEYBLUE550140042050100HANLEY / BLUE / H 550 W 1400 D 420 SH 50 AH 100
3HANLEY / TEAL / H 550 DIA 1400 SH 70HANLEYBLUE550140070HANLEY / BLUE / H 550 DIA 1400 SH 70
Sheet1
Cell Formulas
RangeFormula
K2:K3K2=B2&" / "&C2&" / "&IF(D2," H " & D2,"")&IF(E2," W " & E2,"")&IF(F2," D "&F2,"")&IF(G2," DIA " & G2,"")&IF(H2," SH "&H2,"")& IF(I2," AH "&I2,"")
 
Upvote 0
I would just use the CONCATENATE operator:
=B2&" / "&C2&" / "&IF(D2," H " & D2,"")&IF(E2," W " & E2,"")&IF(F2," D "&F2,"")&IF(G2," DIA " & G2,"")&IF(H2," SH "&H2,"")& IF(I2," AH "&I2,"")

Book1
ABCDEFGHIJK
1TEXTJOIN OUTCOMENAME#1HEIGHT (mm)WIDTH (mm)DEPTH (mm)DIAMETER (mm)SEAT HEIGHT (mm)ARM HEIGHT (mm)RESULT
2HANLEY / TEAL / H 550 W 1400 D 420 SH 50 AH 100HANLEYBLUE550140042050100HANLEY / BLUE / H 550 W 1400 D 420 SH 50 AH 100
3HANLEY / TEAL / H 550 DIA 1400 SH 70HANLEYBLUE550140070HANLEY / BLUE / H 550 DIA 1400 SH 70
Sheet1
Cell Formulas
RangeFormula
K2:K3K2=B2&" / "&C2&" / "&IF(D2," H " & D2,"")&IF(E2," W " & E2,"")&IF(F2," D "&F2,"")&IF(G2," DIA " & G2,"")&IF(H2," SH "&H2,"")& IF(I2," AH "&I2,"")
Thank you and yes you are correct TEAL should be BLUE.
What if I want other fields adding in with " / " as a separator, this is why I started with textjoin. See below expanded example:-

TEXTJOIN OUTCOMENAME#1#2#3#4#5#6HEIGHT (mm)WIDTH (mm)DEPTH (mm)DIAMETER (mm)SEAT HEIGHT (mm)ARM HEIGHT (mm)
HANLEY / BLUE / WOOD EFFECT / BLACK METAL LEGS / BLACK METAL HANDLE / 2 DOOR / LARGE / H 550 W 1400 D 420 SH 50 AH 100HANLEYBLUEWOOD EFFECTBLACK METAL LEGSBLACK METAL HANDLE2 DOORLARGE
550​
1400​
420​
50​
100​
HANLEY / BLUE / WOOD EFFECT / BLACK METAL LEGS / ROUND / H 550 DIA 1400 SH 70HANLEYBLUEWOOD EFFECTBLACK METAL LEGSROUND
550​
1400​
70​
 
Upvote 0
The reason I didn't use TEXTJOIN is because you want added text dependent on whether the cell has a value or not.
 
Upvote 0
But if you want to do it for the first part, do it for the first part.

=TEXTJOIN(" / ",TRUE,A2:H2)&IF(I2," H " & I2,"")&IF(J2," W " & J2,"")&IF(K2," D "&K2,"")&IF(L2," DIA " & L2,"")&IF(M2," SH "&M2,"")& IF(N2," AH "&N2,"")
 
Upvote 0
Thanks
But if you want to do it for the first part, do it for the first part.

=TEXTJOIN(" / ",TRUE,A2:H2)&IF(I2," H " & I2,"")&IF(J2," W " & J2,"")&IF(K2," D "&K2,"")&IF(L2," DIA " & L2,"")&IF(M2," SH "&M2,"")& IF(N2," AH "&N2,"")
Thanks, that is working now however if any of the cells aren't populated then the result contains a lot of spaces, is there anyway to remove these?
 
Upvote 0
See if this does what you want.

23 11 28.xlsm
ABCDEFGHIJKLMN
1TEXTJOIN OUTCOMENAME#1#2#3#4#5#6HEIGHT (mm)WIDTH (mm)DEPTH (mm)DIAMETER (mm)SEAT HEIGHT (mm)ARM HEIGHT (mm)
2HANLEY / BLUE / WOOD EFFECT / BLACK METAL LEGS / BLACK METAL HANDLE / 2 DOOR / LARGE / H 550 W 1400 D 420 SH 50 AH 100HANLEYBLUEWOOD EFFECTBLACK METAL LEGSBLACK METAL HANDLE2 DOORLARGE550140042050100
3HANLEY / BLUE / WOOD EFFECT / BLACK METAL LEGS / ROUND / H 550 DIA 1400 SH 70HANLEYBLUEWOOD EFFECTBLACK METAL LEGSROUND550140070
TJ1 (2)
Cell Formulas
RangeFormula
A2:A3A2=TEXTJOIN(" / ",,B2:H2)&" / "&TEXTJOIN(" ",1,IF(I2:N2="","",LEFT(I$1:N$1,1+2*(LEFT(I$1:N$1,3)="DIA"))&SUBSTITUTE(MID(I$1:N$1,FIND(" ",I$1:N$1)+1,1),"(","")&" "&I2:N2))
 
Upvote 0
See if this does what you want.
If it does, then would it be feasible for you to put the abbreviations required for columns I:N above the existing headings like this? It would make the formulas considerably less complex.

23 11 28.xlsm
ABCDEFGHIJKLMN
1HWDDIASHAH
2TEXTJOIN OUTCOMENAME#1#2#3#4#5#6HEIGHT (mm)WIDTH (mm)DEPTH (mm)DIAMETER (mm)SEAT HEIGHT (mm)ARM HEIGHT (mm)
3HANLEY / BLUE / WOOD EFFECT / BLACK METAL LEGS / BLACK METAL HANDLE / 2 DOOR / LARGE / H 550 W 1400 D 420 SH 50 AH 100HANLEYBLUEWOOD EFFECTBLACK METAL LEGSBLACK METAL HANDLE2 DOORLARGE550140042050100
4HANLEY / BLUE / WOOD EFFECT / BLACK METAL LEGS / ROUND / H 550 DIA 1400 SH 70HANLEYBLUEWOOD EFFECTBLACK METAL LEGSROUND550140070
TJ1 (3)
Cell Formulas
RangeFormula
A3:A4A3=TEXTJOIN(" / ",,B3:H3)&" / "&TEXTJOIN(" ",1,IF(I3:N3="","",I$1:N$1&" "&I3:N3))
 
Upvote 0
Solution
If it does, then would it be feasible for you to put the abbreviations required for columns I:N above the existing headings like this? It would make the formulas considerably less complex.

23 11 28.xlsm
ABCDEFGHIJKLMN
1HWDDIASHAH
2TEXTJOIN OUTCOMENAME#1#2#3#4#5#6HEIGHT (mm)WIDTH (mm)DEPTH (mm)DIAMETER (mm)SEAT HEIGHT (mm)ARM HEIGHT (mm)
3HANLEY / BLUE / WOOD EFFECT / BLACK METAL LEGS / BLACK METAL HANDLE / 2 DOOR / LARGE / H 550 W 1400 D 420 SH 50 AH 100HANLEYBLUEWOOD EFFECTBLACK METAL LEGSBLACK METAL HANDLE2 DOORLARGE550140042050100
4HANLEY / BLUE / WOOD EFFECT / BLACK METAL LEGS / ROUND / H 550 DIA 1400 SH 70HANLEYBLUEWOOD EFFECTBLACK METAL LEGSROUND550140070
TJ1 (3)
Cell Formulas
RangeFormula
A3:A4A3=TEXTJOIN(" / ",,B3:H3)&" / "&TEXTJOIN(" ",1,IF(I3:N3="","",I$1:N$1&" "&I3:N3))
This has worked a dream! Thank you.
 
Upvote 0

Forum statistics

Threads
1,216,028
Messages
6,128,382
Members
449,445
Latest member
JJFabEngineering

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