Send cell data from one Google sheet to another and then overwrite data

僤鯓⒐⒋嵵緔 提交于 2019-12-13 04:27:40

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!