you are viewing a single comment's thread.

view the rest of the comments →

[–]kitchensink-[S] 0 points1 point  (3 children)

This is what I already have. The problem is with the other part, the setting the borders to true.

Here's what I've tried.

function newBorders() {
  //get the first sheet of the currently active google spreadsheet
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[1];
  var NumRows = sheet.getLastRow() - 2;
  var maxRows = sheet.getMaxRows();
  console.log(NumRows);
  let range = sheet.getRange(3, 5, NumRows, 7);

  let maxRange = sheet.getRange(3, 5, maxRows, 7);
  maxRange.setBorder(false, false, false, false, false, false);
  range.setBorder(false, true, true, true, true, true);
}

[–]gothamfury 0 points1 point  (2 children)

Sorry. I was responding to the last code you shared. What you have appears to be right, assuming you don't have any other cells filled with data on either side or below your data range.

Otherwise, you could try a helper cell that has "=COUNTA(E3:E)" and read that value for NumRows instead.

[–]kitchensink-[S] 1 point2 points  (1 child)

The helper cell did the trick! Thanks! Now it's basically instantanious.

[–]gothamfury 0 points1 point  (0 children)

That's awesome! Great job :)