For some reason, historyQuery2
returns the proper data range, but historyQuery1
returns 0.
function getEventHistory(cS,findAcct) {
// copy filtered values from Events sheet to Client sheet (cS)
var historyCell = cS.getRange("E5");
var historyQuery1 = "=query(Events!A1:AH,\"select * where A = " & findAcct & "\")";
var historyQuery2 = "=query(Events!A1:AH,\"select * where A = 808998\")";
historyCell.setFormula(historyQuery2);
}
I know I can use filters but I find queries run far faster (the Events worksheet is around 12000 rows).
I was expecting a subset of the Events sheet that met the query criteria (Column A equals findAcct).
What I get is a zero (0).
I've tried eval (ick) but no difference. I've tried forcing the findAcct variable (which is an integer) into a string. I've tried passing the query string to the function. I've tried declaring historyQuery as a const. Still no luck.
The problem seems to lie in the historyQuery1
string. When I try to output that string using Browser.MsgBox as a debug, I also get zero (0), but historyQuery2
query string appears in the message box.