Google Sheets – Is There a Way to Set Different Formulas for Multiple Areas at the Same Time?

In my question Is there a way to set different values ​​for multiple areas at the same time? I've found out how to set different values ​​for non-contiguous cells at the same time, and we've come up with a good answer to that.

Now I want to set several different formulas for non-contiguous cells at the same time, but there is a problem. Unlike specifying values, the formula array replaces the entered values ​​and deletes the entire target area.

My test data:

 | B  |   C    |  D  |
2|   2|       5|    8|
3|   3|       6|    9|
4|   4|       7|   10|
5|   9|kitty   |puppy|
6|fawn|duckling|joey |

Here is my test code:

  var testSheet = spreadSheet.getSheetByName("Tests");

  function testSetFormulas() {
    var cell = testSheet.getRange("B5:D6");
    var formulas = cell.getFormulas();

    formulas(0)(0) = "=SUM(B2:B4)";
    formulas(1)(1) = "=AVERAGE(C2:C4)";


If i use the string (no formula) kitty in the cell C5this code is blowing that away.

I just want to set the formulas for B5 and C6 without side effects.

I tried to set an array member for C5 on the value "kitty", I tried too null and undefined and "",

formulas(0)(1) = "kitty";
formulas(0)(1) = null;
formulas(0)(1) = undefined;
formulas(0)(1) = "";

Each approach still blows the content away C5 if C5 contains only one value, no formula. (It respects existing formulas)

Is there a way to write multiple formulas at the same time without replacing existing values ​​in cells that do not need formulas that I want to leave alone?