formula to combine cell

tonywatsonhelp

Well-known Member
Joined
Feb 24, 2014
Messages
3,210
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
Hi Everyone,
I need a formula to combine the data from B2:B10 but include
"|"
between each value, but also cope if some cells don't have a value

So
=B2&"|"&B3&"|"&B4&"|"&B5&"|"&B6&"|"&B7&"|"&B8&"|"&B9&"|"&B10 would work but I need it to deal with empty cells?

Tony
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hopefully you are using Excel 2016 via Office 365, then

=TEXTJOIN("|",TRUE,B2:B10)


Otherwise it might be helpful to know something about what could be in those cells (numbers, single word, multiple words, complete mixture?)
 
Upvote 0
In Excel 2016, you could use TEXTJOIN but in earlier versions you'll need CONCAT with an array formula:


Book1
BCD
2aa|b|d|f|g|i
3ba|b|d|f|g|i
4
5d
6
7f
8g
9
10i
Sheet1
Cell Formulas
RangeFormula
D2=TEXTJOIN("|",TRUE,B2:B10)
D3{=MID(CONCAT(IF($B$2:$B$10="","","|"&$B$2:$B$10)),2,1024)}
Press CTRL+SHIFT+ENTER to enter array formulas.


The 1024 is just an arbitrary big number.

WBD
 
Upvote 0
In Excel 2016, you could use TEXTJOIN but in earlier versions you'll need CONCAT with an array formula:

@ WBD
Note that for TEXTJOIN, your 2016 Excel must be through Office 365, not the stand-alone version.
Also, my understanding is that CONCAT was also only introduced for the same version.
References:
https://support.office.com/en-us/article/textjoin-function-357b449a-ec91-49d0-80c3-0e8fc845691c
https://support.office.com/en-us/article/concat-function-9b1a9a3f-94ff-41af-9736-694cbd6b4ca2

@ Tony
I asked the additional questions in case you didn't have the appropriate Excel version.

If the cells are blank or contain numbers or single words (ie no spaces) then try C3 below

If the cells can contain text with spaces then try F2

Excel Workbook
BCDEF
2aa|b|c|d|fa doga dog|a cat|99|three mice|f
3a|b|c|d|f
4ba cat
5c99
6dthree mice
7
8
9ff
10
Join
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,244
Members
452,622
Latest member
Laura_PinksBTHFT

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