Match Function with Google Sheets Apps Script -JavaScript IndexOf Method Tutorial – Part 16




Learn how to create Google Sheets Match function alternative using JavaScript in Apps Script.

Original source


10 responses to “Match Function with Google Sheets Apps Script -JavaScript IndexOf Method Tutorial – Part 16”

  1. Hi! In the 11:00 minute the log returns the value 0.0.
    I can understand that why the lookupRangeValues.indexOf(lookupValue) returns something like false ( in this case 0.0), but than you add 1 to it , so why isn't it returns 1.0?
    Could you help me with that? Thank you for your answer in advance.

  2. Question, I want to use the same idea but instead of search in what column, I need what row. the problem is that the values are arrays inside of singles arrays. I want to find the name: "John" and the …getRange(2, 2, lr, 1).getValues(); –> is [ [Carlos], [Mike], [John], [Tom]… ]

    I do not know why when we look by columns the values are simple as an array inside of and array, any tricks?

    for now I a using Match function in the sheet and then I get the value to the scrip.

    Regards
    CW

  3. The log says "Undefined". Can you help me what's wrong with my script, @Learn Google Spreadsheets?
    As note: I have "Sheet1" and "Sheet2", and the column "Alfa", "Beta", Gamma".

    Here is my script:

    function myFunction(){
    var index = ColumnIndex("Sheet1","Beta");
    Logger.log(index);
    }

    function ColumnIndex(sheetname,columnlabel){
    var activeSheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(sheetname);
    var lastColumnIndex = activeSheet.getLastColumn();
    var headers = activeSheet.getRange(1, 1, 1, lastColumnIndex).getValues()[0];
    var columnIndex = headers.indexOf(columnlabel)+1;
    }

  4. Hi LCS, Thanks for this video. Can you please help me out with an issue I am facing? My range is a single column. when i am cheking the logs, I am getting only the 1st element of the column.

    var arr2 = ss.getRange(2,1,r-1,1).getValues()[0];
    Logger.log(arr2);

    result = [Dog] (complete contents of the column -> Dog, Cat, Deer, Mouse, Dog)

    Thanks

Leave a Reply