Created
June 29, 2016 13:32
-
-
Save jrumbut/d803229ff550d8fb9da2e427ad9893f6 to your computer and use it in GitHub Desktop.
Google Sheets Copy On Condition
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function copyOnConditional() { | |
var ss=SpreadsheetApp.getActiveSpreadsheet();// some global variables | |
var master = ss.getSheetByName('Raw Data'); | |
var colWidth = master.getMaxColumns(); | |
//function copyRowsOnCondition() { | |
var data = master.getDataRange().getValues(); | |
for(n=2;n<data.length;++n){ | |
//if(data[n][1].length<16){ // if not pre-filled with your text | |
var start_date = new Date(data[n][7]); | |
var dest = ss.getSheetByName(start_date.getFullYear().toString());//remove any spaces that could be included in the name so the name = sheetName for sure | |
if(!dest) { | |
var dest = ss.insertSheet(start_date.getFullYear().toString()); | |
} | |
var dest2 = ss.getSheetByName(data[n][6]); //user role | |
if(!dest2) { | |
var dest2 = ss.insertSheet(data[n][6]); | |
} | |
var destRange = dest.getRange(dest.getLastRow()+1,1);// the place to write | |
var dest2Range = dest2.getRange(dest2.getLastRow()+1,1);// the place to write | |
master.getRange(n+1,1,1,colWidth).copyTo(destRange);//the copy itself value & format | |
master.getRange(n+1,1,1,colWidth).copyTo(dest2Range);//the copy itself value & format | |
//} | |
} | |
//} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment