Tabel Otomatis Pada Spreadsheet
1. Copy Spreadsheet (Klik Disini)
2. Klik menu Ekstensi/Extensions lalu pilih Apps Script.
3. Terdapat file default bernama Code.gs
4. Copy dan pastekan script di bawah ini ke Code.gs
Masukkan Password Untuk Melihat Script (Password ada di dalam video)
//www.javabitpro.com
function onEdit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Tabel Otomatis'); // apply to sheet name only
var rows = sheet.getRange('D4:H'); // range to apply formatting to
var numRows = rows.getNumRows(); // no. of rows in the range named above
var values = rows.getValues(); // array of values in the range named above
var testvalues = sheet.getRange('D4:D').getValues(); // array of values to be tested (1st column of the range named above)
rows.setBorder(false, false, false, false, false, false, "black", SpreadsheetApp.BorderStyle.SOLID); // remove existing borders before applying rule below
for (var i=0; i <= numRows-1; i++) {
var n = i + 4;
//www.javabitpro.com
if (testvalues[i] > 0) { // test applied to array of values
sheet.getRange('D' + n + ':H' + n).setBorder(true, true, true, true, true, true, "black", SpreadsheetApp.BorderStyle.SOLID); // format if true
}
}
};
//www.javabitpro.com
function onEdit() {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheetByName('Tabel Otomatis'); // apply to sheet name only
var rows = sheet.getRange('D4:H'); // range to apply formatting to
var numRows = rows.getNumRows(); // no. of rows in the range named above
var values = rows.getValues(); // array of values in the range named above
var testvalues = sheet.getRange('D4:D').getValues(); // array of values to be tested (1st column of the range named above)
rows.setBorder(false, false, false, false, false, false, "black", SpreadsheetApp.BorderStyle.SOLID); // remove existing borders before applying rule below
for (var i=0; i <= numRows-1; i++) {
var n = i + 4;
//www.javabitpro.com
if (testvalues[i] > 0) { // test applied to array of values
sheet.getRange('D' + n + ':H' + n).setBorder(true, true, true, true, true, true, "black", SpreadsheetApp.BorderStyle.SOLID); // format if true
}
}
};