function getFormulasFromSelectedRange() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var range = sheet.getActiveRange(); // Gets the currently selected range
var formulas = range.getFormulas(); // Retrieves the formulas in the selected range
var output = [];
for (var i = 0; i < formulas.length; i++) {
for (var j = 0; j < formulas[i].length; j++) {
if (formulas[i][j]) { // Only add if there's a formula
output.push(
"Cell " + range.getCell(i + 1, j + 1).getA1Notation() + ": " + formulas[i][j]
);
}
}
}
Logger.log(output.join("\n")); // Logs all formulas and their locations
}