Thursday, 9 March 2023

Google Sheet + Apps Script : Day02(Removes/Blanks Cell containing Digit/Number)

 

This code helps remove all numbers in 3rd column of third sheet in a SpreadSheet.


function numberRemoverFromColumn() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[2];
  //  var sheet = ss.getSheetByName("SheetName"); 
 
 var row=1;
  var startRowAt=2; //starting row
  var endRowAt=2192;//last row

  for ( row=startRowAtrow<endRowAtrow++ ) {
    var range = sheet.getRange(row,3);
    var presentCellValue =range.getValues(); //=values[0][0];
      if(presentCellValue%2===0 || presentCellValue%2===1){
        Logger.log(presentCellValue+" will be blanked now");
        var richValue = SpreadsheetApp.newRichTextValue()
                        .setText("")
                        .build();
        range.setRichTextValue(richValue)
      }
  }
}



No comments:

Post a Comment