保存正在编辑的单元格的脚本

时间:2017-12-06 14:10:18

标签: google-apps-script google-sheets

如何创建脚本保存正在编辑的单元格? (基本上让脚本按下"输入"然后继续)。

我试图找到一种万无一失的方法,因为这个电子表格是供同事使用的。

我已尝试function onOpen() { var AcksSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Acks"); var RecruiterList = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Lists"); var RecruitersRange = RecruiterList.getDataRange(); var nLenRecruitersTable = RecruitersRange.getNumRows(); var values = RecruitersRange.getValues(); var email = Session.getActiveUser().getEmail(); var nRecruiterRow = 0 for (var i = 0; i < nLenRecruitersTable; i++) { // check if active user email matches email in the recruiter table if (email == values[i][1]) { // plus one as the range has one row header nRecruiterRow = i+1; AcksSheet.getRange(nRecruiterRow,2).setValue(new Date()); AcksSheet.getRange(nRecruiterRow,2).setNumberFormat("MM/dd/yyyy hh:mm:ss"); break; } } } / <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.bundle.min.js" integrity="sha384-3ziFidFTgxJXHMDttyPJKDuTlmxJlwbSkojudK/CkRqKDOmeSbN6KLrGdrBQnT2n" crossorigin="anonymous"></script> 设置其他单元格处于活动状态,但这不起作用(因此,最后一个已编辑但未经过验证的单元格未被采用脚本帐户。

2年前似乎问过同样的问题: How do I deselect an active cell when clicking on an image to run a script?

但是没有答案。

0 个答案:

没有答案