问题
I have a Google sheet (Employee Timesheet) that documents employees' hours each day for the week. Once that week has finished (Monday - Friday) the data gets the overwritten with next weeks data. I need the data to be sent to another Google Sheet (Employee Data) where it will be stored. How can I send that data for it then to be documented and not removed once overwritten the following week?
回答1:
you will need something like this:
function tc() {
var reference = 'sheet1!A2';
var rng = SpreadsheetApp.getActiveSpreadsheet().getRange(reference);
rng.setValue(rng.getValue()+1);
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var ss = SpreadsheetApp.getActiveSpreadsheet ();
var source = ss.getRange ("Sheet1!A5:H");
var destSheet = ss.getSheetByName("Sheet2");
var values = source.getValues().filter(function(e) {return e.some(function(f) {return f})});
destSheet.getRange(destSheet.getLastRow() + 1, 1, values.length, values[0].length).setValues(values);
}
anytime cell sheet1!A2
changes the range Sheet1!A5:H
gets archived in Sheet2
来源:https://stackoverflow.com/questions/55777831/send-cell-data-from-one-google-sheet-to-another-and-then-overwrite-data