所以我用多张表格制作了这个月的每一天(1-31)的电子表格,有一名工作人员在关闭诊所(这是一家医疗诊所)之前,每天都会输入我们所做的内容(借方、贷方) 、现金、费用)。她只能访问每张纸的相同的某些范围;我锁定了所有工作表,但这些范围(她可以编辑的范围)除外。
问题是,当她第二天上班回来并登录电子表格时,她仍然可以编辑前几天的内容;我要做的就是每天晚上把当天工作表的单元格例外情况拿出来,这样她就无法在通过后编辑前几天的工作了。
是否有一个脚本可以让我每天设置自动删除某些工作表的这些范围例外?例子: 24 年 1 月 1 日 20:00h 锁定表 1,无范围异常。 24 年 1 月 2 日 20:00h 锁定表 2,无范围异常。 24 年 1 月 3 日 20:00h 锁定表 2,无范围异常。 依此类推,直到31号。
我从每张工作表中解锁(工作人员可以编辑的范围)的范围是: (G5)/(G20:G23)/(A9:G17)/(G27)/(A47:G49)/(A33:G41)
我希望脚本锁定的工作表的名称是: “1”一直到“31”
非常感谢您的帮助。
您有一个包含 31 个工作表的电子表格(名为 1-31):每个月的每一天都有一个工作表;工作人员使用电子表格;每天交易后,您锁定电子表格,除了某些设置为“不受保护”的特定单元格/范围;结果是,工作人员可以查看前一个交易日的表格,但只能编辑那些特定的未受保护的单元格/范围。您需要一个时间触发的函数,该函数将在交易日的晚上运行,以保护交易日表并删除特定的未受保护的单元格。
试试这个功能。 注意事项:
day-of-month
事件对象准确。逻辑
day-of-month
事件对象。function tradingDayUpdate(e) {
// Logger.log(JSON.stringify(e)) // DEBUG
// list of trading day sheets
var sheetNames = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31]
var ss = SpreadsheetApp.getActiveSpreadsheet()
// get the Event Object for the day of the month
var dayOfMonth = e['day-of-month']
// Logger.log("DEBUG: The day of the month: "+dayOfMonth)
// find the index matching the day of the month
var dayMatch = sheetNames.indexOf(dayOfMonth) // zero-based
// Logger.log("DEBUG: dayMatch = "+dayMatch)
// get the actual SheetNumber
var sheetName = sheetNames[dayMatch]
// Logger.log("DEBUG: Trading Day sheet number = "+sheetName)
// get the sheet and activate (make it the Activesheet)
var sheet = ss.getSheetByName(sheetName);
sheet.activate();
// Protect the active sheet, then remove all other users from the list of editors.
var protection = sheet.protect().setDescription("Protected Trading Day#"+sheetName);
// Ensure the current user is an editor before removing others. Otherwise, if the user's edit
// permission comes from a group, the script throws an exception upon removing the group.
var me = Session.getEffectiveUser();
protection.addEditor(me);
protection.removeEditors(protection.getEditors());
if (protection.canDomainEdit()) {
protection.setDomainEdit(false);
}
// Gets the description of the protected sheet and logs it to the console.
var sampleProtectedSheetDescription = protection.getDescription();
// Logger.log(""+sampleProtectedSheetDescription);
}