I created a “form” in google sheets and I protected the sheet except for some editable ranges that require an answer. I need the values from those unprotected cells and copy them in a row to another sheet.
I found a solution from another forum that simply selects all the concerned fields. But I don’t want to hardcode the range / cell location because I might add need to edit it in the future.
This is what I have so far:
function cpydata() {
const ss = SpreadsheetApp.getActiveSpreadsheet(); // <<< current spreadsheet
const s1 = ss.getSheetByName("Template");
const s2 = ss.getSheetByName("Summary");
const data = ss.getDataRange().getValues();
const out = [data[1][2], data[2][2], data[3][2], data[4][2], data[5][2], data[6][2]];
s2.getRange(s2.getLastRow()+1, 1, 1, out.length).setValues([out]);
}
Screenshot of the File
The cells in red are unprotected ranges.
Any ideas?
Thanks!
Cookie is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.