Reputation: 13
=query(LT!B:E,"Select E where D matches """&LessonPlan!A4&""" or
B matches """&LessonPlan!A4&""" label E '' ")
Would anyone be willing to tell me how to change this into google scripts? Your help would be greatly appreciated! Have a great holiday and thanks for the help!
Upvotes: 1
Views: 106
Reputation: 27302
I guess something like this should do it:
function myFunction() {
var ss = SpreadsheetApp.getActive()
var source = ss.getSheetByName('LT');
var outputSheet = ss.getActiveSheet();
var matchval = ss.getSheetByName('LessonPlan')
.getRange('A4')
.getValue();
var val = source.getRange(2, 2, source.getLastRow(), 4)
.getValues();
var arr = [];
for (var i = 0, l = val.length; i < l; i++) {
if (val[i][0] == matchval || val[i][2] == matchval) arr.push([val[i][3]]);
}
outputSheet.getRange(1, 1, arr.length, arr[0].length)
.setValues(arr);
}
Note: the sheet where the results are written is now set to the active sheet. You may need to change that ... Hope this helps ?
Upvotes: 1