someone asked these questions but it's not working, if possible, make corrections on the test file, please Any of between N16:N29, 16 to 29 any one cell we select that cell text or value shows on yellow N10
In Google Sheets, is it possible to display the contents of the active cell to another cell?
About your request of Any of between N16:N29, 16 to 29 any one cell we select that cell text or value shows on yellow N10
, how about the following sample script?
Please copy and paste the following script to the script editor of your provided Google Spreadsheet, and save the script. And, just in case, please reopen Google Spreadsheet.
function onSelectionChange(e) {
const sheetName = "Form"; // This is from your provided Spreadsheet.
const { range } = e;
const sheet = range.getSheet();
const check = sheet.getSheetName() == sheetName && range.rowStart >= 16 && range.rowEnd <= 29 && range.columnStart == 14;
const value = check ? range.getValue() : null;
sheet.getRange("N10").setValue(value);
}
When this script is used using your provided Spreadsheet, the following result is obtained.
This sample script is for your provided Spreadsheet. So, please test this script using your provided Spreadsheet.
The function onSelectionChange
is automatically run by the simple trigger when a cell is selected. I used onSelectionChange
of the simple trigger from Any of between N16:N29, 16 to 29 any one cell we select that cell text or value shows on yellow N10
. So, when you directly run the function onSelectionChange
with the script editor, an error like TypeError: Cannot destructure property 'range' of 'e' as it is undefined.
occurs, because the event object e
is not given. Please be careful about this.
About your following reply,
it's working but if I have to remove this const value = check? range.getValue() : null; Means Whenever its out of range it will keep the old value is it possible?
In this case, how about the following sample script?
function onSelectionChange(e) {
const sheetName = "Form"; // This is from your provided Spreadsheet.
const { range } = e;
const sheet = range.getSheet();
const check = sheet.getSheetName() == sheetName && range.rowStart >= 16 && range.rowEnd <= 29 && range.columnStart == 14;
if (!check) return;
sheet.getRange("N10").setValue(range.getValue());
}