Concatenate, If, blanks, brackets and text

gingerexcel

New Member
Joined
Apr 28, 2022
Messages
3
Office Version
  1. 365
Platform
  1. MacOS
Hi

I have spent far too long on this.....

I have up to 5 columns that I want to concatenate. Some are blank, some have values.

I always want to concatenate A2 and B2 (straightforwards), then I want a s. in front of C2, then only if not blank, D2 should have brackets around it, and only if not blank, E2 should have brackets around it.

1651149173751.png


I get close, but I can't work out a way to handle the combination of blanks and not blanks without ending up with a rogue close brackets or open brackets. The spreadsheet has a few thousand rows.

Thanks so much, genii
 

Attachments

  • 1651149133660.png
    1651149133660.png
    7.2 KB · Views: 2
  • 1651149162174.png
    1651149162174.png
    8.7 KB · Views: 2

Excel Facts

Waterfall charts in Excel?
Office 365 customers have access to Waterfall charts since late 2016. They were added to Excel 2019.
Welcome to the Board!

Why doesn't the third example have "1971" in the desired result?
Is that a typo, or is there more logic there that needs to be accounted for?
 
Upvote 0
If that was just a typo and the 1971 should be there, try this formula for an entry on row 2:
Excel Formula:
=A2&" "&B2&IF(C2<>""," s."&C2,"")&IF(D2<>""," ("&D2&")","")&IF(E2<>"","("&E2&")","")
 
Upvote 0
Solution
Welcome to the Board!

Why doesn't the third example have "1971" in the desired result?
Is that a typo, or is there more logic there that needs to be accounted for?
Sorry it was a typo! Corrected version below.

1651150627713.png
 
Upvote 0
OK, my formula above should do what you want.
 
Upvote 0
Another option
Excel Formula:
=TEXTJOIN(" ",,A2:B2,IF(C2="","","s."&C2),IF(D2:E2="","","("&D2:E2&")"))
 
Upvote 0
If that was just a typo and the 1971 should be there, try this formula for an entry on row 2:
Excel Formula:
=A2&" "&B2&IF(C2<>""," s."&C2,"")&IF(D2<>""," ("&D2&")","")&IF(E2<>"","("&E2&")","")
Genius, thank you, you've saved me!
 
Upvote 0
You are welccome!
Glad we were able to help!
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,260
Members
449,075
Latest member
staticfluids

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