I am having one google sheet (sheet1) of supplier details. The column names are CODE, SUPP, PLACE with rows of around 300 plus. When I want to search the supplier name having "IMPEX", I am using following google sheet query formula:
=QUERY(Sheet1!A1:C200, "SELECT A, B, C WHERE B CONTAINS '%IMPEX%' ",1)
the Google sheet query is fetching the details. And the results comes as following, which is fine.
CODE SUPP PLACE
1138 IMPEX STEELS PVT LTD BANGALORE
1278 SHIVAM IMPEX LTD BANGALORE
1345 IMPEX INC, CHENNAI
1456 RADHE STEEL IMPEX MUMBAI
Now I want to use this in Google Apps Script. I wrote the following code but it is not working. Could someone edit or rectify it?
function searchName{
var ss = SpreadsheetApp.getActiveSpreadsheet();
var ws = ss.getSheetByName("Sheet1");/
var dr = ws.getRange("A1:C360");
var data = dr.getValues();
//show the search results in the same sheet on D15 cells
Var D15 = ws.getRange("D15:F20")
var result = [];
for (var i =0; i< data.length; i++){
if(data[i][1] = "IMPEX"){
result.push(data[i]);
// Logger.log(result)
d15.displayRow(result);
}
}
}