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

前端 未结 10 811
情书的邮戳
情书的邮戳 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条回答
  •  借酒劲吻你
    2020-11-29 02:48

    This simple code did the job for me!

        function myFunction() {
    
          var ss = SpreadsheetApp.getActiveSpreadsheet();  // get active spreadsheet
    
          var activeRow = ss.getActiveRange().getRowIndex();  // get active/selected row
    
    var start=1;
    var end=650;
    var match='';
    var match2=0;   //Edit this according to your choice.
    
         for (var i = start; i <= end; i++) {
          var columnC = ss.getRange("C"+i).getValue();
          if (columnC ==match  || columnC ==match2){ ss.deleteRow(i); }
         }
        }
    

提交回复
热议问题