Conditional concatenation and commas

  • Thread starter Thread starter Blasting Cap
  • Start date Start date
B

Blasting Cap

I have several rows & cols in a spreadsheet that I need to concatenate
the columns for.

The source is:

A1 = Name1 B1 = 2 C1= 3
A2 = Name2 B2 = C1 = 5
A3 = Name3 B2 = 1 C1 =
A4 = Name4 B2 = 3 C1 = 2

The result would look like:

A1 = Name1 D1 = 2,3 (the concatenation of B1 & C1)
A2 = Name2 D1 = 5
A3 = Name3 D1 = 1
A4 = Name4 D1 = 3,2

Where there are 2 numbers, I want to include a comma, but where there is
one number I do not want to include a comma.

Any help appreciated.

BC
 
BC: Try this:

=IF(OR(ISBLANK(B1),ISBLANK(C1)),CONCATENATE(B1,C1),CONCATENATE(B1,",",C1))

Mark
 
Are you looking for a fomula in D1

=if(len(trim(B1))=0,C1,if(len(trim(C1))=0,B1,B1&","&C1))

Assumes both B and C will not be blank.
 
Hello Blasting Cap,

Here is another formula, This one doesn't care if "B" or "C" is blank.

=IF(AND(B1<>"", C1<>""), B1 & "," & C1, IF(B1="", C1, B1))

Sincerely,
Leith Ros
 
Back
Top