Im using this below method to search data from a google sheet using google apps scricpt. its working fine but can someone please tell me how to set search function to find data only from one column? for now it`s getting data related to keyword from whole data range. (Not expecting the change data range fix. I need to search keyword only in one column)
Reference site : https://www.bpwebs.com/create-web-forms-to-get-data-from-google-sheets/#index-file
function searchonecol() {
const ss = SpreadsheetApp.getActive();
const sh = ss.getSheetByName('SheetName');
const sr = 2;//data start row
const colnum = 1;//column number
const haystack = sh.getRange(sr,colnum,sh.getLastRow() - sr + 1).getValues();
haystack.forEach((r,i) => {
if(r[0] == 'needle') {
SpreadsheetApp.getUi().alert('you just found the needle in the haystack');
}
});
}