I would like to have borders on rows where the first cell of a row has a specific color.
I found this script, and tried modifying to to my needs.. but without success.
function border1() {
var sheet1 = SpreadsheetApp.getActiveSheet();
var range = sheet1.getRange("A1:B50");
var backgrounds = range.getBackgrounds();
var counter = 0;
var gray = "#efefef";
for (var i = 0; i < backgrounds.length; i++){
if(backgrounds[i]== gray)
//counter++;
range.setBorder(true, false, true, true, true, true);
}
Logger.log(counter);
//range.setBorder(true, false, true, true, true, true);
}
The problem is that when I run this, all my cells are borderd instead of the row with the specific color. I think the command range.setborder has to refer to the cells with the background -->> (backgrounds[i]) ???