I was researching how to "Add a border to the whole row if a cell in column D is not empty" – I've found similar script but I failed to edit it to my need!
Below is the script I found – I already allow trigger of the script upon spreadsheet opening but still doesn't work.
Link from original discussion:
Conditionally format row borders
function onEdit(event) {
var sheet = SpreadsheetApp.getActiveSheet();
var range = event.range;
var startingRow=range.getRow();
var numRows = range.getNumRows();
for (var i = 1; i <= numRows; i++) {
var rowNbr=startingRow+i-1;
Logger.log("changed row %s",rowNbr );
//Now check the WHOLE row
var colLeft=1; //1=A
var colRight=10; //10=J
var row = sheet.getRange(rowNbr,colLeft, 1, colRight-colLeft+1);
if(row.isBlank()) {
row.setBorder(false, null, null, null, null, null, "black",
SpreadsheetApp.BorderStyle.SOLID_MEDIUM);
} else {
row.setBorder(true, null, null, null, null, null, "black",
SpreadsheetApp.BorderStyle.SOLID_MEDIUM);
}
}
}
Best Answer