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

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
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,236
Messages
6,170,912
Members
452,366
Latest member
TePunaBloke

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