google apps script - OnOpen or time trigger - move rows to another spreadsheet if 2 criteria met -
i have little experience, in fact near none of terminology 'herd' not known.
i have 2 spreadsheets 1 sheet named same in each.
spreadsheet "production" sheet "master" - sheet id 1gog0ts1_2jwlgretreynrvk-q6tey3iwg_5vxfozlus
spreadsheet "archived_production" "master" - sheet id 1mr4ljmp1smpds1i8u_pe5uloevjlc599vq87m9hwcx0
with onopen script, or maybe timed trigger, set in "production" spreadsheet need move rows "archived_production" spreadsheet meet 2 criteria
criteria 1 - date in column b 7 days older current date
but if, also
criteria 2 - entry in column o "100%"
in included screenshot example, given today's date 11/19/14, first entry highlighted in yellow moved upon next opening of spreadsheet.
thank you, always, in advance help.
sorry, not enough postings yet allow image upload, text explains.
you can use function perform operation want on onopen()
script.
function onopen() { // moved data sheet1 sheet2 var production_sheet_id = 'put production sheet's id here'; // source sheet var archived_sheet_id = 'put archived sheet's id here'; // destination sheet var sheet1 = spreadsheetapp.openbyid(production_sheet_id).getsheets()[0]; var sheet2 = spreadsheetapp.openbyid(archived_sheet_id).getsheets()[0]; var rows = sheet1.getdatarange(); var numrows = rows.getnumrows(); var values = rows.getvalues(); (var = 0; < numrows; i++) { var olddate = values[i][1]; // or var olddate = new date('values[i][1]') var curdate = new date(); // count time difference in milliseconds, convert them days then. var diffinmillisecs = (curdate.gettime() - olddate.gettime()); var diffindays = diffinmillisecs/1000/60/60/24; var diffindays = math.round(diffindays); if(values[i][14] == 1.0 && math.abs(diffindays+30) >= 7) // evaluates 100% 1.0 sheet2.appendrow(values[i]); } }
Comments
Post a Comment