Delete a row in Google Spreadsheets if value of cell in said row is 0 or blank

前端 未结 10 821
情书的邮戳
情书的邮戳 2020-11-29 02:01

I\'d like to be able to delete an entire row in a Google Spreadsheets if the value entered for say column \"C\" in that row is 0 or blank. Is there a simple script I could w

10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-29 02:50

    This is what I managed to make work. You can see that I looped backwards through the sheet so that as a row was deleted the next row wouldn't be skipped. I hope this helps somebody.

      function UpdateLog() {
    
      var returnSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('RetLog');
      var rowCount = returnSheet.getLastRow();
    
      for (i = rowCount; i > 0; i--) {
        var rrCell = 'G' + i;
        var cell = returnSheet.getRange(rrCell).getValue();
        if (cell > 0 ){
          logSheet.
          returnSheet.deleteRow(i);
        }
      }
    }
    

提交回复
热议问题