Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

Border Formating

$
0
0

I am looking to format cells with a border if the title cells both contain text. To trial I have used number 1 for the search key. I think it may be in the range I am supplying for the .setBorder.

Final Product would look like the attached image. Final Product

function onEdit(){

  var sheetName = 'Sheet1'; //Customizable

  var ss = SpreadsheetApp.getActiveSpreadsheet();

  var sheet = ss.getSheetByName(sheetName);

  var rangeAll = sheet.getRange(1,1,20,20);

  var cellColumnStart = 1;

  var cellRowStart = 1;

  var numRows = rangeAll.getNumRows();

  var numColumns = rangeAll.getNumColumns();

  var testValues = rangeAll.getValues();

 rangeAll.setBorder(false, false, false, false, null, null, "black", SpreadsheetApp.BorderStyle.SOLID); //remove existing borders 

  for  (var i=1; i < numRows-1; i++){

    for (var j=1; j < numColumns-1; j++){

      if (testValues[1][j] == '1'&& testValues [i][1] == '1') {

        var rangeCell = sheet.getRange(i,j);

        rangeCell.setBorder(true, true, true, true, null, null, "black", SpreadsheetApp.BorderStyle.SOLID); //box borders 

      }     

    }

  }

}

Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>