Search Active Sheet Google apps script lesson Search Active Sheet to find matching text results

Apps Script – Search Active Sheet to find matching text results of cells

Use of the createTextFinder method to search a sheet object and return back the matching results.  To get the first value use the method findNext() in the results which is an iterator.  To convert all the matching results into an array object use the findAll() method.  This will return an array format object that contains the cells as items in the array.   From here you can use array methods to interact with the items in the found results.

function searchIt() {

 const sheet = SpreadsheetApp.getActiveSheet();

 const findString = ‘dog’;

 const textFinder = sheet.createTextFinder(findString);


 const items = textFinder.findAll();


 //const cell = textFinder.findNext();


   const row = cell.getRow();

   const col = cell.getColumn();


   Logger.log(`Found at Row:${row} Col:${col}`);



WP Twitter Auto Publish Powered By :