I'm very comfortable with Sheets/Excel, but still learning Apps Script.
I want to replicate the "Filter" function (or Query) right in my script.
Meaning:
function imports() {
// @NotOnlyCurrentDoc
var values = SpreadsheetApp.openById('spreadsheetid').
getSheetByName('Sheet1').getRange('a:b').getValues();
SpreadsheetApp.getActive().getSheetByName('Sheet2').
getRange(1,1,values.length,values[0].length).setValues(values);
}
The above script will import a range from one sheet to another -- is there a way to tweak this into recreating something like = Filter(A:A,A:A="test") ---- meaning, the import would only include values where Col A is a specific value??
Additionally I'd be looking to only select specific columns (not all of A:G).. I use Query for this in a Sheet, saying QUERY((Filter A:A,A:A="Test"),"SELECT Col1, Col4")
Is there a way to include select specific columns in a full range?
I constantly run into this where I'm importing data, and then have to filter/query in the sheet, rather than getting ahead of the problem from the script.
Any thoughts?