enter image description hereI am looking to achieve an app script that will export a full row of information based on two arguments.
In the spreadsheet attached in the screenshot you will see that all yellow columns will be populated based on an intake form. What I am looking to do is test if column G has either "BPO", "VA" or "T". But I want to only run this if the checkbox in column H is true. If both arguments are true I want to export to a different page in the same workbook.
Any assistance is greatly appreciated!
CodePudding user response:
You should be able to use the query function in Google Sheets to complete this.
The basic syntax is:
QUERY(Range of Data,select statement for your fields)
So in your instance in Cell A1 of each of your seperate sheets you would want
=query(Form!A:H,"Select * where G like 'VA%' and C like 'Video'",1)
You would then need to change the formula on each tab so that the two like elements match the criteria for that tab i.e. BPO and Video ect
CodePudding user response:
Export on meeting requirements
function elxporto() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName("Sheetname");
const osh = ss.getSheetByName("Export");
const vs = sh.getRange(3,1,sh.getLastRow() - 2,sh.getLastColumn()).getValues();
const g = ["BPO","VA","T"];
let d = 0;
vs.forEach((r,i) => {
if(g.some(e => r[6].includes(e)) && r[7] == 'TRUE') {
osh.getRange(osh.getLastRow() 1, 1, r.length).setValues(r);
osh.deleteRow(i 3 - d );
}
});
}