Search code examples
google-sheetsarray-formulas

Googlesheet merge 2 cells in next column based on their content


I have a Googlesheet with Column A= ID like B-124992 or D-133739 and several different ID's as well, Column B= Title description. I want to Merge only the "B-" and "D-" -like ID's with their respective Title description. I'm using ArrayFormula in column C like:

= ArrayFormula(IF(ISNUMBER(FIND({"B-","D-"};'BacklogData'!A2));A2&" - "&B2;""))

The result is merging as expected but the output is distributed in column C (shows all "B-" merge results) and column D ((shows all "D-" merge results).

How can I get the results all in column C?


Solution

  • In C2 try:

    =ArrayFormula(if(len(B2:B); if(regexmatch(A2:A; "(B-|D-)"); A2:A&"-"&B2:B;);))
    

    This will reference the colA and output the concatenation of col A and colB if col A starts with either B- or D. NOTE: you will have to erase all formulas you currently have in col C.

    Hope that helps ?

    EDIT: not sure if you are referencing another sheet, but in that case you will have to add in the sheet name, like you did in the example you gave.