Search Dialog Sample using TextFinder with Google Apps Script


This is a sample script for the search dialog using TextFinder with Google Apps Script. If this sample script could help to indicate the possibility of TextFinder, I’m glad.


In this demonstration, the value of test is searched. When "NEXT" is clicked, the next searched value is activated. When "PREVIOUS" is clicked, the previous searched value is activated. The search can be done for all sheets in the Google Spreadsheet.

Sample script

When you use this script, please copy and paste the following script to the container-bound script of Google Spreadsheet, and run the function of run(). By this, a dialog is opened to the Spreadsheet.

function searchText(searchValue, c) {
  const ranges = SpreadsheetApp.getActiveSpreadsheet()
  if (c < ranges.length) {
    return c;
  return --c;

function run() {
  const htmlStr = `
<input type="text" id="searchText" name="searchText">
<button id="previous" onclick="googleScript(c > 0 ? c - 1 : 0)">PREVIOUS</button>
<button id="next" onclick="googleScript(++c)">NEXT</button>
let c = -1;
const googleScript = (i) => => c = cc).searchText(document.getElementById("searchText").value, i);
  const htmlObj = HtmlService.createHtmlOutput(htmlStr)
  SpreadsheetApp.getUi().showModelessDialog(htmlObj, "sample");