Search code examples
excelconcatenationstring-concatenation

not CONCATENATE row if one cell is empty


I have text data in A2, B2 and C2 cells. In this moment I set:

E2 =CONCATENATE(A2;B2;C2)

But how can I set E2 so to NOT CONCATENATE three of them at all - and leave E2 blank - if B2 is empty?

Thank you


Solution

  • In the most recent versions of Excel you can put the following formula inside E2 cell:

    = IF(B2 <> "", CONCATENATE(A2, B2, C2), "")
    

    while for my Excel 2007 this was the right one:

    = IF(B2 <> ""; CONCATENATE(A2; B2; C2); "")
    

    It means that if B2 is not empty [<> means different, "" means empty] then you CONCATENATE. Otherwise you leave it empty

    The general syntax for newer versions is the following:

    = IF(test, [if true], [if false])
    

    while for the past ones:

    = IF(test; [if true]; [if false])