Google Sheets – Bảo vệ ô chứa công thức (How to protect cells that contain formulas)
Code sử dụng trong hướng dẫn:
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu(‘THC Menu’)
.addItem(‘Protect Fx’, ‘protectFormulas’)
.addToUi();
}
function protectFormulas() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getActiveSheet();
const range = sh.getDataRange();
const formulas = range.getFormulas();
formulas.forEach((r, i) => {
r.forEach((c, j) => {
if (c != ”) {
sh.getRange(i + 1, j + 1).protect().setDescription(‘Bảo vệ công thức hàm —- Tin học Cộng’);
}
});
});
Browser.msgBox(“Hoàn thành!”)
}
0 responses on "Google Sheets - Bảo vệ ô chứa công thức (How to protect cells that contain formulas)"