0
我正在尝试在Google Spreadsheets中为特定工作表编写代码,该代码已设置为在特定工作表上工作,可以使用数组完成此工作,还是会在此处创建问题是我有:Google电子表格中的时间戳
原始代码:
function onEdit() {
// writes the current date to the last cell on the row when a cell in a specific column is edited
// adjust the following variables to fit your needs
var sheetNameToWatch = "Sheet1";
var columnNumberToWatch = 20;
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getActiveCell();
if (sheet.getName() == sheetNameToWatch && range.getColumn() == columnNumberToWatch) {
var targetCell = sheet.getRange(range.getRow(), sheet.getLastColumn());
targetCell.setValue("" + Utilities.formatDate(new Date(), "GMT", "yyyy-MM-dd"));
}
}
氏是我一直想(目前没有工作)
function onEdit() {
var repArray = new Array();
var allSheets = ss.getSheets();
for (i in allSheets) {
if ((allSheets[i].getName()).match(/.*?\.$/))
{repArray.push(allSheets[i].getName());}
}
var sheetArray = [];
for (var j in repArray) {
var tempSheet = ss.getSheetByName(repArray[j]);
var sheetNameToWatch = "tempSheet";
var columnNumberToWatch = 11
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getActiveCell();
if (sheet.getName() == sheetNameToWatch && range.getColumn() == columnNumberToWatch) {
var targetCell = sheet.getRange(range.getRow(), 1); // I choose 1 because the Date Stamp should be placed in Column A
targetCell.setValue("" + Utilities.formatDate(new Date(), "GMT", "dd-MM-yy"));
}
}
此电子表格是由不同的销售代表的工作在每个有表格中有他们的名字(最后还有一段时间来构建数组),所以当有人更新列K时,我希望datestamp被放置在它们各自的表格的列A上,但目前为止我还没有完成它。
嘿帕特里克纽格鲍尔我试过的代码,但它不工作...它有点不会做任何事情,并且...什么表情正在寻找是包括期间的任何表,如果没有时间然后再没有必要将表添加到数组 –
酷的工作原理是这是它应该做的日期应该在第一列进行更改 –