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

前端 未结 10 816
情书的邮戳
情书的邮戳 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

    quite simple request. Try this :

     function try_It(){
     deleteRow(2); //// choose col = 2 for column C
     }
    
     function deleteRow(col){ // col is the index of the column to check for 0 or empty
     var sh = SpreadsheetApp.getActiveSheet();
     var data = sh.getDataRange().getValues();
     var targetData = new Array();
     for(n=0;n

    EDIT : re-reading the question I'm not sure if the question is asking for a 'live' on Edit function or a function (like this above) to apply after data has been entered... It's not very clear to me... so feel free to be more accurate if necessary ;)

提交回复
热议问题