I have a function that I want to search through a given sheet and return an array of cells containing the custom function "POPULATE". The function currently returns a string array of each instance of "=POPULATE".
function formulaSearch() {
var sheet = spreadsheet.getSheetByName('test');
var range = sheet.getDataRange();
var values = range.getValues();
var formulas = range.getFormulas();
// Search for all cells with the POPULATE function and put them into array
var cells = [];
for (var row in formulas) {
for (var col in formulas[row]) {
if (formulas[row][col].indexOf("=POPULATE") > -1 ) {
cells.push(formulas[row][col]);
Logger.log(cells);
}
}
}
return cells;
}
How can I return an array of cells in A1 notation of each cell that contains the formula? I know of the .getA1Notation() method but I can't convert the elements in the returned array to the Range data type.
formulas[row][col]is just aStringcontaining the cell's formula, not the actual cell. - Bobbyrogers