Reputation: 506
I am using this formula to concatenate the contents of several cells into a single cell:
=B2 & " - " & F2 & G2 & " - " & H2
However, F2, G2, and H2 may sometimes be blank. Here's how my concatenated cell looks when all of those cells have values:
B2 content - F2 content G2 content - H2 content
and here's how it looks if F2 and G2 have no data:
B2 content - - H2 content
How I can I set up the formula so that the extra dashes and spaces would be hidden in that second example, leaving me with "B2 content - H2 content"?
Thanks!
Upvotes: 0
Views: 232
Reputation: 26
Try the following Code:
=IF(B2="","",B2&" - ")&IF(F2="","",F2&" - ")&IF(G2="","",G2&" - ")&IF(H2="","",H2)
Upvotes: 1
Reputation: 96773
Perhaps:
=IF(F2 & G2<>"",B2&" - "&F2&G2&" - "&H2,B2 & " - " & H2)
Upvotes: 1