Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
970 views
in Technique[技术] by (71.8m points)

google apps script - Copy every row of Data from one sheet that has a given value in column K to another sheet

I'm working on a Google Spreadsheet the will use a Script to copy every row of Data from one sheet that has "Done In The Past 30 Days" in column K to another sheet.

By "sheet" I mean every tab. Source tab is "Arley" destination tab is currently "ArleysSandbox" Every row has ll columns, A-K. The entire row should be carried over. The number of total rows in the sheet will increase over time. Every time I run the Script, I want it to clear all existing data on "ArleysSandbox" first. Column K, where it says "Done In Past 30 Days" is a formula. I will eventually want to pull from multiple sheets and compile on the Sandbox sheet.

I was using a post from the old forum as a starting point but got stuck due to my lack of knowledge. http://productforums.google.com/forum/#!msg/apps-script/FNGzVkEqZh4/x8WCYtjvpI8J Thanks in advance for any suggestions.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
//Find current filter and remove     
var currentFilter = master_sheet.getFilter();
      if ( currentFilter !== null ) {
        master_sheet.getFilter().remove();
      } 
     var master_lr=master_sheet.getLastRow();
     var master_lc=master_sheet.getLastColumn();


//Apply filter here
      master_sheet.getRange(1,1,master_lr,master_lc).createFilter();
      var criteria = SpreadsheetApp.newFilterCriteria().setHiddenValues(['Reject','Approved']).build();
      master_sheet.getFilter().setColumnFilterCriteria(45, criteria);

      master_sheet.getFilter().getRange().copyTo(harmonize_approvers.getRange(1,1,master_lr-1,master_lc), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...