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

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
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), " & ")
 
Upvote 0
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.

 
Upvote 0
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), " ")
 
Upvote 0
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.
 
Upvote 0

Forum statistics

Threads
1,214,943
Messages
6,122,380
Members
449,080
Latest member
Armadillos

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