Google-sheets – Conditional Find and Replace in Google Sheets

google sheetsgoogle-sheets-arrayformularegex

Example data:

A    B
------
1    HELLO
2    HELLO
2    HELLO
3    HELLO

I want to replace $ with , WORLD! but only if A is equal to 2. Such that the final result would be:

A    B
------
1    HELLO
2    HELLO, WORLD!
2    HELLO, WORLD!
3    HELLO

Best Answer

Please use the following arrayformula in conjunction with 2 nested IF functions. Adjust ranges to your needs:

=ArrayFormula(IF(P2:P<>"", 
           IF(P2:P=2,Q2&", WORLD",Q2),""))

enter image description here