Learn how to create Google Sheets Match function alternative using JavaScript in Apps Script.
Original source
Match Function with Google Sheets Apps Script -JavaScript IndexOf Method Tutorial – Part 16
Tags
Apps Script, function, Google Sheets, how-to, indexOf, javascript, javascript tutorial, learn, match, method, tutorial
Share :
- tweet
-
About the : d4mer
JavaScript To Do List App Tutorial
May 25th, 2020JavaScript Tutorial-6 IF ELSE
May 24th, 2020Web automation with JavaScript for beginners | Puppeteer
May 23rd, 202010 Comments
Leave A Comment
You must be logged in to post a comment.
Rashid Anwar
You are doing a great job. Keep it up and thank you.
David Marcadet
Great vidéo, thank you so much!
Daniel Ramel
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.
rockster rakesh
thankz for this great video bro….
JesucristoNuestroSalvador
how can I execute script with a key like the enter ? Excelent … God Bless You.
Carlos Wild
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
Computer Geeks
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;
}
Vivek Martin
Nice one! Thanks! Wondering if I can make this work with data in a single column and match values on multiple rows?
abhishek singh
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
Laza Lazarevic
Welcome back 🙂 and thanx for another great video