google-apps-scriptgoogle-sheetswebapp2

Google sheet + Web app search specific column and return all matching rows


Anybody knows how can I amend the code below to only search from a specific column in Google sheet e.g. column J?

The code below works great and returns the entire row that matches the searchtext, but the search is across the entire range within the google sheet. https://www.bpwebs.com/create-web-forms-to-get-data-from-google-sheets/comment-page-1/#comments


Solution

  •   const colIndex = 9; // Column J
      data.forEach(function(f) {
        if (f[colIndex] == searchtext) {
          ar.push(f);
        }
      });