Answer the question
In order to leave comments, you need to log in
How to paint the border of a merged cell using Google App Script?
Column "A" lists auto parts, many of the rows are merged (only in column "A"). After each spare part, there is a border in the entire line. I used to do them manually, today I decided to fix it with a script.
I’ll tell you about the script, how it works: Since I can’t know about all the additional properties of the spare parts in advance, I first remove all lower bounds through the loop, then I use this loop:
var ranges = [];
for(var i = 1; i < firstColumn.length; i++)
{
if(firstColumn[i][0])
{
ranges.push("A" + i + ":" + i);
}
}
return sheet.getRangeList(ranges).setBorder(null, null, true, null, null, null);
Answer the question
In order to leave comments, you need to log in
Example https://docs.google.com/spreadsheets/d/1xa_zzf6P1n...
function myFunction() {
const book = SpreadsheetApp.getActiveSpreadsheet();
const sheet = book.getSheetByName('Sheet1');
const ranges = ['B1', 'B4', 'B6', 'B9'];
sheet.getRangeList(ranges).setBorder(null, null, true, null, null, null);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question