[英]Google sheet protect based on cell value
我在一個谷歌表格文件中有 30 個標簽,它們都具有相同的結構但數據不同
我想要一個根據值鎖定(保護)整個工作表的腳本
此值被定義為范圍,如果該值是(已審核),我想鎖定選項卡
function protectAudited() {
var ss=SpreadsheetApp.getActive();
var shts=ss.getSheets();
shts.forEach(function(sh) {
if(sh.getRange('A5').getValue()=='audited') {
sh.protect();
}
});
}
也許像這樣:
function protectAudited() {
var ss=SpreadsheetApp.getActive();
var shts=ss.getSheets();
shts.forEach(function(sh) {
if(sh.getRange('A5').getValue()=='Audited') {
sh.protect();
}else {
var protection=sh.getProtections(SpreadsheetApp.ProtectionType.SHEET)[0];
if(protection && protection.canEdit()) {
protection.remove();
}
}
});
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.