Трудно сказать без самого скрипта
Не этот случайно?(я тут жестко задал 2лист)
/**
* Simple trigger that runs each time the user hand edits the spreadsheet.
*
* @param {Object} e The onEdit() event object.
*/
function onEdit(e) {
if (!e) {
throw new Error(
'Please do not run the onEdit(e) function in the script editor window. '
+ 'It runs automatically when you hand edit the spreadsheet.'
);
}
copyRowWhenCheckboxTicked_(e);
}
/**
* When a checkbox is ticked, copies columns A:F of the active row
* to the sheet named in row 3.
*
* @param {Object} e The onEdit() event object.
*/
function copyRowWhenCheckboxTicked_(e) {
'use strict';
try {
if (e.value !== 'TRUE') {
return;
}
const ss = SpreadsheetApp.getActive();
const sheet = e.range.getSheet();
const values = sheet.getRange(`A${e.range.rowStart}:F${e.range.rowStart}`).getValues().flat();
const targetSheetName = sheet.getRange(3, e.range.columnStart).getValue();
const targetSheet = ss.getSheetByName('Лист2');
if (!targetSheet) {
throw new Error(`Cannot find sheet '${targetSheetName}'.`)
}
targetSheet.appendRow(values);
showMessage_(`Copied row ${e.range.rowStart} to sheet '${targetSheetName}'.`);
} catch (error) {
showAndThrow_(error);
}
}
/**
* Shows error.message in a pop-up and throws the error.
*
* @param {Error} error The error to show and throw.
*/
function showAndThrow_(error) {
// version 1.0, written by --Hyde, 16 April 2020
var stackCodeLines = String(error.stack).match(/\d+:/);
if (stackCodeLines) {
var codeLine = stackCodeLines.join(', ').slice(0, -1);
} else {
codeLine = error.stack;
}
showMessage_(error.message + ' Code line: ' + codeLine, 30);
throw error;
}
/**
* Shows a message in a pop-up.
*
* @param {String} message The message to show.
* @param {Number} timeoutSeconds Optional. The number of seconds before the message goes away. Defaults to 5.
*/
function showMessage_(message, timeoutSeconds) {
// version 1.0, written by --Hyde, 16 April 2020
SpreadsheetApp.getActive().toast(message, 'Custom script', timeoutSeconds || 5);
}