Conditional CONCAT function

miva0601

New Member
Joined
Mar 31, 2015
Messages
33
Hello,
I'm looking for an excel formula (or macro) that would look at the columns of each row and if there is a value it would concatenate it with the next column that has a value and add a space. Using only the CONCAT function results results in extra spaces, since it's not guaranteed that there will be a value in each column.

Book11
ABCDEFG
1CustomerBPRGCRGPRHMDesired Result
22699GPR GPR GPR
34229GCR GCR GCR
47347GPRHM GPR HMGPR HM
512951GCRHM GCR HMGCR HM
616171HM HMHM
719069GPR GPR GPR
824466BPRGPRBPR GPR BPR GPR
963447GPR GPR GPR
10714010BPRGPRHMBPR GPR HMBPR GPR HM
11760825BPRHMBPR HMBPR HM
Sheet1
Cell Formulas
RangeFormula
F2:F11F2=CONCAT(B2," ",C2," ",D2," ",E2)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
If you have CONCAT, then you should have TEXTJOIN
Excel Formula:
=TEXTJOIN(" ",1,C2:E2)
 
Upvote 0
Solution
Whilst I'd go with the textjoin function, if you want to use concat you could do it like
Excel Formula:
=TRIM(CONCAT(B2," ",C2," ",D2," ",E2))
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,287
Members
452,631
Latest member
a_potato

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