Find Cell Matching Value And Return Rownumber

后端 未结 4 508
名媛妹妹
名媛妹妹 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

    Here the code

    function rowOfEmployee(){
      var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
      var data = sheet.getDataRange().getValues();
      var employeeName = sheet.getRange("C2").getValue();
      for(var i = 0; i

    When you want to perform this kind of lookup it is better to retrieve data with sheet.getDataRange().getValues() because in this case you will get data as a table of values this is faster. When you use the standard EmployeeSheet.getRange(2,3,1,1).getValue() in fact you retrieve an object which need more time to be processed and each time you query the spreadsheet.

    In my exemple I made only one query to retrieve all data instead n query to retrieve one data each time.

    Stéphane

提交回复
热议问题