I new to scripting and have a range of data 3 columns wide which I would like to add borders to based on column 1. I need to check to see if the cell (cells) immediately below is a blank or non-blank cell. If the cell (or cells) below are blank I want include those cells when setting the border but having some issues. Any help would be appreciated.
I have tried something like this but no luck
var range = sheet.getRange(row,1, totalrows,3);
var data = range.getValues();
for (i=0; i<data.length; i++) {
if(data[i][0] != "" &&
data[i+1][0] != "")
{
sheet.getRange(i,1,1,3).setBorder(true,true,true,true,true,false);}
}
sheet, rows and totalrows have been defined earlier
any help would be appreciated
If I'm understanding correctly, this might me one way:
var counter = 1;
for (var i = 1, length = data.length; i <= length; i++)
{
if (i == length || data[i][0])
{
sheet.getRange(i + row - counter, 1, counter, 3).setBorder(true,true,true,true,true,false);
counter = 1;
}
else
{
counter++;
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.