我可以一次保护2或3号范围的电池吗?

问题描述 投票:0回答:1

https://i.stack.imgur.com/7LagU.png

我已经尝试搜索一种方法,但是不太确定要搜索此问题的关键字。有没有一种方法可以命名单元格?

google-sheets google-sheets-formula
1个回答
0
投票
问题:

保护仅适用于SheetRange,不适用于list of ranges。因此,您无法同时保护它们。参见Protect, hide, and edit sheets

解决方法:

但是,如果您愿意使用Apps Script,则可以使用一个脚本来保护两个范围:

var sheet = SpreadsheetApp.getActiveSheet(); var range1 = sheet.getRange("E3:F3"); var protection1 = range1.protect(); var range2 = sheet.getRange("H3"); var protection2 = range2.protect(); var protections = [protection1, protection2]; protections.forEach(protection => { var me = Session.getEffectiveUser(); protection.addEditor(me); protection.removeEditors(protection.getEditors()); if (protection.canDomainEdit()) { protection.setDomainEdit(false); } });

参考:

© www.soinside.com 2019 - 2024. All rights reserved.