I'm trying to follow this YouTube tutorial and it has already what I specifically need. It's a tutorial on GOOGLE SHEET - APPS SCRIPT. I'm trying to get the ROW NUMBER from a specified range. It's just that my data range of reference is vertical instead of horizontal. But when I try to edit the code, it returns an error value of -1. Could someone help me with this?
Here is the YouTube link that I am following: https://www.youtube.com/watch?v=1SIN5NyQ9fw&t=926s
Here's what I currently have. And if I understand correctly, the problem should be within lines 18 and 19 (see below). I could be wrong though.
var makes = datass.getRange( 2, 2, datass.getLastRow(), 1).getValues();
var makeIndex = makes[0].indexOf(activeCell.getValue());
Will appreciate the help! Thanks so much!!
function myFunction() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
}
function onEdit(){
var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var datass = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("ITEMS");
var activeCell = ss.getActiveCell();
if(activeCell.getColumn() == 2 && activeCell.getRow() > 1){
var makes = datass.getRange( 2, 2, datass.getLastRow(), 1).getValues();
var makeIndex = makes[0].indexOf(activeCell.getValue());
Logger.log(activeCell.getValues());
Logger.log(makes[0]);
Logger.log(makeIndex);
ss.getRange("E10").setValue(makeIndex);
}
}