Cell is formula? In googlescript

Viewed 1738

I want to do an action if the selected cell is formula, how do I do?

Some command like isformula() of Google Sheets.

Ex.: if (cell == "formula"?) {make something} else {make something}

2 Answers

getFormula return true if there is a formula and false if it doesn't. There is no need to check the string for "=".

if (range.getFormula()) {
  ui.alert('has formula: ' + range.getFormula()); 
} else {
  ui.alert('no formula: ' + range.getFormula());  
}
Related