Find Cell Matching Value And Return Rownumber

后端 未结 4 505
名媛妹妹
名媛妹妹 2020-12-13 09:31

The employee sheet contains the name of the employee in cell C2. The name of the employee should also be on the data sheet in the range B3:B153.

How can I get the ro

4条回答
  •  轮回少年
    2020-12-13 10:07

    I faced this problem today and I found a native method to do the job.

    Here is the snippet to test if it works for you:

      var spreadsheet = SpreadsheetApp.getActive();
      var tosearch = "your text to search";
      var tf = spreadsheet.createTextFinder(tosearch);
      var all = tf.findAll();
      
      for (var i = 0; i < all.length; i++) {
        Logger.log('The sheet %s, cell %s, has the value %s.', all[i].getSheet().getName(), all[i].getA1Notation(), all[i].getValue());
      }
    

提交回复
热议问题