The employee sheet contains the name of the employee in cell C2. The employee name must also be indicated in the data sheet in the range B3: B153.
How can I get the cell number of a cell in a data sheet that matches the employee name?
I tried the following script, but it does not work.
var Sheet = SpreadsheetApp.getActive(); var Employeesheet = Sheet.getSheetByName('Employee') var DataSheet = Sheet.getSheetByName('Data'); var Column = Sheet.getRange(3,2,151,1); var Values = column.getValues(); var Row = 0; while ( Values[Row] && Values[Row][0] !=(EmployeeSheet.getRange(2,3,1,1).getValue()) ) { Row++; } if ( Values[Row][0] === (EmployeeSheet.getRange(2,3,1,1).getValue()) ) return Row+1; else return -1; }
google-spreadsheet google-apps-script google-docs row-number value google-sheets
LennartB
source share