Google-sheets – Update Cell If another cell is not empty

google sheetsgoogle-apps-script

There are two columns N and O.

When any cell in column N is filled the adjoining cell in column O needs to filled with "Yes" if not it stays empty.

This is the script I'm using.

var s = SpreadsheetApp.getActiveSheet();
    if( s.getName() == "Sheet 1" ) 
    {
        var r = s.getActiveCell();
           if( r.getColumn() == 14 && r.getValue() == '') 
           {
              var nextCell = r.offset(0, 2);
                  nextCell.setValue("YES");
           }
    }

How can I change/modify the above script to show if when a cell is filled in a particular column then the adjoining cell shows as "Yes"

Or simply put translate this formula into a script

=if(ISBLANK(N2),"","Yes")

Without using it in this form

var cell = sheet.getRange("C2:C1000");
cell.setFormula("=if(ISBLANK(N2),"","Yes")");

Best Answer

Simply use this formula :

=ARRAYFORMULA(IF(A1:A="INVOICE NO.","SUPPLIER MAIL",IF(ISBLANK(A$1:A),"","YES")))

And erase any manual value under B1.
This should work.