Google apps script Google应用程序脚本从单元格复制到新行
我的谷歌电子表格中有两张表格Google apps script Google应用程序脚本从单元格复制到新行,google-apps-script,Google Apps Script,我的谷歌电子表格中有两张表格 主跟踪 每日跟踪 主跟踪从其他跟踪表中提取信息,并更新单元格M7中每个驾驶员的行驶里程数 我想用日期(A列)和行驶英里数(B列)设置每日跟踪 我想写一个谷歌应用程序脚本,将复制主跟踪数据!M7添加到每日跟踪(B列),但每次运行脚本时都添加到新行。我计划在每个工作日结束时使用触发器使其运行 到现在为止我还有这个,但它不起作用 function copyFunction() { var inputRange = SpreadsheetApp.getActiveSp
function copyFunction() {
var inputRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Master Tracking").getRange("M7:M7");
var inputValues = inputRange.getValues();
var outputRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Daily Tracking").getRange("B:B").getLastRow();
outputRange.setValue(inputValues);
}
我想不出来。我可以将它粘贴到一个特定的单元格中,但我不知道如何将它粘贴到新行中。也许getLastRow会有用。我不知道
另外,如何将时间戳放在每日跟踪的a列中
请帮忙 没有测试它,但应该可以工作:(参见代码中的注释)
function copyFunction() {
var inputRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Master Tracking").getRange("M7");
var inputValue = inputRange.getValue();// use simple getValue without S, get a simple value
var last = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Daily Tracking").getLastRow();// get the last row on this sheet
var outputRange = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Daily Tracking").getRange(last+1,1,1,2);// getRange col A & B +1 after last row
outputRange.setValues([[Utilities.formatDate(new Date(), Session.getTimeZone(), 'MM-dd-yyyy'),inputValue]]);// date string in col A and value in col B in a 2D array (note the S in setValues) -
}