Concatenate cells and adding l sign and skip black cell

westie54

New Member
Joined
Feb 25, 2016
Messages
3
Hi

Currently I am using this formula....

=SUBSTITUTE(TRIM(D3&"^"&E3&" ^ "&F3&" ^ "&G3&" ^ "&H3&" ^ "&I3&" ^ "&J3&" ^ "&K3&" ^ "&L3&" ^ "&M3&" ^ "&N3&" ^ "&O3&" ^ "&P3&" ^ "&Q3&" ^ "&R3&" ^ "&S3&" ^ "&T3&" ^ "&U3&" ^ "&V3&" ^ "&W3&" ^ "&X3&" ^ "&Y3&" ^ "&Z3),"^", " l ")

But the issue is it substitute ^ with l so I got as a result....

l l l l Apple & Pear l l Flower & Nature l l l l l l l l l

If I replace ^ with blank (" "), " l " would replace all the spaces so the result will be like below which is not what I want.
Apple l & l Pear l Flower l & l Nature

<tbody>
</tbody>

<tbody>
</tbody>
What I am after is Apple & Pear l Flower & Nature

Can anyone advise me what formula to us please?
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
24,208
If l l l l Apple & Pear l l Flower & Nature l l l l l l l l l is in A1

=SUBSITUTE(SUBSITUTE(TRIM(SUBSITUTE(SUBSITUTE(A1," & ",CHAR(5)),"|" " "))," ","|"),CHAR(5), " & ")
 

westie54

New Member
Joined
Feb 25, 2016
Messages
3
Hi Mike,

The data that I want to draw data from is from column D2 to Z2. Do I need to repeat the A1," & ",CHAR(5) to get a complete formula? Sorry if my question sounds silly (this shows how little I know about excel). Thank you.

 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
24,208
The formula that you are currently using:

=SUBSTITUTE(TRIM(D3&"^"&E3&" ^ "&F3&" ^ "&G3&" ^ "&H3&" ^ "&I3&" ^ "&J3&" ^ "&K3&" ^ "&L3&" ^ "&M3&" ^ "&N3&" ^ "&O3&" ^ "&P3&" ^ "&Q3&" ^ "&R3&" ^ "&S3&" ^ "&T3&" ^ "&U3&" ^ "&V3&" ^ "&W3&" ^ "&X3&" ^ "&Y3&" ^ "&Z3),"^", " l ")

I'm not sure why you are going through the carets, but to get a delimited string that preserves the existing spaces, you could replace each of those cell references with
SUBSTITUTE(D3," ",CHAR(5))
SUBSTITUTE(E3," ",CHAR(5))
SUBSTITUTE(F3," ",CHAR(5))
And use the (shortened) formula
=SUBSITUTE(SUBSTITUTE(TRIM(SUBSTITUTE(D3," ",CHAR(5))&" "&SUBSTITUTE(E3," ",CHAR(5))&" "&SUBSTITUTE(F3," ",CHAR(5))), " ", " | "), CHAR(5), " ")
 

mikerickson

MrExcel MVP
Joined
Jan 15, 2007
Messages
24,208
On the other hand, it would be much much easier to have a helper row

in D4 put the formula =D3
In E4 put the formula =IF(D4="", E3, IF(E3="", D4, D4 & " | " & E3)

Then drag right.
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,190
Messages
5,835,896
Members
430,393
Latest member
hetherton

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
Top