Skip to content

Instantly share code, notes, and snippets.

@supernovaplus
Last active June 20, 2019 19:26
Show Gist options
  • Save supernovaplus/584484edc031d003b93d3b38b96816f7 to your computer and use it in GitHub Desktop.
Save supernovaplus/584484edc031d003b93d3b38b96816f7 to your computer and use it in GitHub Desktop.
function MoveBatEmployeesInactiveSheetWhoLeftCompany() {
var console = {log: function(item){return Logger.log(item)}}
var spreadsheet = SpreadsheetApp.getActive();
var sheet1 = spreadsheet.setActiveSheet(spreadsheet.getSheetByName('Vouchers'), true);
var ActiveEmployeeArray = sheet1.getRange('S4:S132').getValues().filter(function(item){return item[0]!="";})
var sheet2 = spreadsheet.setActiveSheet(spreadsheet.getSheetByName('InactiveList'), true);
var ScanningThisArray = sheet2.getRange('I2:I173').getValues();
console.log(ScanningThisArray.length+" X "+ActiveEmployeeArray.length);
for (var i = 0; i < ScanningThisArray.length; i++) {
if(ScanningThisArray[i][0]=="")continue;
var EmployeeFound = false;
for (var k = 0; k < ActiveEmployeeArray.length; k++) {
if(ScanningThisArray[i][0]===ActiveEmployeeArray[k][0]){
EmployeeFound=true;
break;
}
}
ScanningThisArray[i][1]=EmployeeFound;
if(!EmployeeFound){
var value = sheet2.getRange("I"+(i+2))
sheet2.getRange("Q"+(i+2)).setValue(value.getValue());
value.setValue("");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment