I want to keep the cell data as it is for those cells which have no formula applied.
The code snippet explains the function.
this solution too overwrites the values, setFormulas won't skip empty array elements, over-writes values
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getDataRange();
var Formulas = range.getFormulas();
for (var i in Formulas) {
for (var j in Formulas[i]) {
if (Formulas[i][j] == "") //cells which dont have the formula
{
//dont apply any formula, but keep the existing cell data (as it is)
} else {
Formulas[i][j] = '=HYPERLINK("http://www.google.com","Google")'
}
}
}
range.setFormulas(Formulas);