下記の例では1カラム目に日付が入ります。updateByDay
をトリガーで定期実行すると、1日1回のみ行が足されていきます。
function insertToday(sheetName) { var spreadsheetObj = SpreadsheetApp.getActiveSpreadsheet(); var sheet = spreadsheetObj.getSheetByName(sheetName); var today = new Date(); var formatToday = Utilities.formatDate(today, "Asia/Tokyo", "yyyy-MM-dd"); var lastRow = sheet.getLastRow(); var range = sheet.getRange(lastRow,1); var dateColumn = range.getValue(); if(Utilities.formatDate(dateColumn, "Asia/Tokyo", "yyyy-MM-dd") != formatToday) { var newRow = sheet.getRange(lastRow+1,1); newRow.setValue(formatToday); } return formatToday; } function updateByDay() { var spreadsheetObj = SpreadsheetApp.getActiveSpreadsheet(); var sheet = spreadsheetObj.getSheetByName("sheet"); var formatDate = insertToday("sheet") var source = sheet.getRange(sheet.getLastRow()-1,2,1,50); source.copyTo(sheet.getRange(sheet.getLastRow(),2,1,50)); }