No video

How to VLOOKUP in Google Sheets with Apps Script?

  Рет қаралды 38,749

Learn Google Sheets & Excel Spreadsheets

Learn Google Sheets & Excel Spreadsheets

Күн бұрын

Learn how to do a VLOOKUP in Google Sheets in Apps Script using JavaScript.
#vlookup #googlesheets #script

Пікірлер: 84
@nikkiacute
@nikkiacute Жыл бұрын
this is amazing, thank you. So well explained and easy to follow for noobs like me. And I can see you're responding to people too - really helpful! How do you ignore a blank row please? my spreadsheet is active so new rows added all the time, I'd like to run the function on rows containing data only.
@AlberichRheinmann
@AlberichRheinmann 6 ай бұрын
Thanks a lot for your interesting videos ... and many thanks for your wonderful presentation. You would be ( are ) a very good teacher 😊❤
@oneup2022
@oneup2022 Жыл бұрын
Thank you 🙏for sharing this great knowledge. One query though, can we make this script conditional based on column label, I mean whenever we run this script it will first search for specific column label, then it will paste the matching values. I would be so grateful if some one address this query.
@ElizabethGemmell-ss2ue
@ElizabethGemmell-ss2ue 2 ай бұрын
This code does ALMOST exactly what I want it to when applied to my spreadsheet, but it doesn't automatically update when modifying or adding rows to, using your example, the "sales data" sheet. I modified your code to use dynamic ranges rather than static, but it still doesn't update without having to run the code again, which is problematic for a number of reasons. Also, I would prefer if it simply skipped rows that didn't match rather than giving an output, as those rows in my spreadsheet are non-recurring events, and are inputted manually, so I'd appreciate it if it would stop replacing those values with a 0. Any tips?
@kulvinder8211
@kulvinder8211 2 жыл бұрын
sir ,What should I do if I want to pick the value of 2 columns.
@koonerhospitalitygroup9688
@koonerhospitalitygroup9688 Жыл бұрын
see below; the example retrieves 2 columns. You just need to make sure that the number of null statements is the same as the number of columns your getting and then for your set values you need to make sure that the number of columns matches. const matchSku = searchValues.map(searchRow => { const matchRow = srcdata.find(r => r[0] == searchRow[0]) {return matchRow ? [matchRow[4],matchRow[0]] : [[null],[null]]} })
@johnstewart2945
@johnstewart2945 Жыл бұрын
Spot on, this is so helpful. As someone new to Apps Script coding, this was a great help. How can the return be modified to skip updating (and not overlay with [null] when a match doesn't exist)? The line of code that I'd like to update to skip updating rows that don't match is currently: return matchRow ? [matchRow[7]] : null? Thank you so much!
@user-zl1hz5cj7n
@user-zl1hz5cj7n Жыл бұрын
My question is that in VBA we can utilize Worksheet fomulas in script e.g. we can write down Vlookup in Script and get the values in script, and it is far more easier to get things through scripts. Is there anyway one can get such support in Google sheet, since sheet formulas are also part of Google sheet
@rajeshr8887
@rajeshr8887 2 жыл бұрын
Interesting and well explained as always! You make learning App Scripts for dummies like me a breeze.
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
:)
@sephamdan6182
@sephamdan6182 5 ай бұрын
why i cant run setvalues from the result of array that have one row three column ? instead my getrange for paste it has 1 row 3 column please answer teacher.
@erikaknollenberg7526
@erikaknollenberg7526 Жыл бұрын
This is excellent, thank you. I'm wondering how to do this when the sheet doesn't know that it's Column H it needs to go into. Instead, to find that it's Column H and them proceed from there?
@anetawieczorek3360
@anetawieczorek3360 Жыл бұрын
Thank you so much. It work, but my data are transpossed. May you please advice how this loop should look like if Sales Date would be transposed - data from Sales Rep (col C) would be places in columns from B1 to DF1 (for eg.110 positions instead of 2041) and matched values should be returned to B10 to DF10 ( or at best to first empty row ).
@birendraprasadsah5517
@birendraprasadsah5517 2 жыл бұрын
Awesome👍
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
Thanks 🤗
@erniyunita1285
@erniyunita1285 5 ай бұрын
Is the performance be better if we use app script?
@muhammadhaseeb6677
@muhammadhaseeb6677 2 жыл бұрын
Exactly what I was searching today , then just fond that you uploaded this video one day before. Great video, Keep it up. I am learning a lot from you :)
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
:)
@antonellogenco7821
@antonellogenco7821 4 ай бұрын
Hi, thanks for the video, very useful, what happens in case of duplicate values? I assume it takes all the values, but how can I modify the code to make the match not just one column but two columns? EX: Take all the values of column number 4 if NAME = ISABELLA and SURNAME = BRANDON? Thank you
@imamfachrudin7846
@imamfachrudin7846 2 жыл бұрын
can we have trigger for this? in case there's any additional data from worksheet regularly
@Anakinr13
@Anakinr13 Жыл бұрын
The .find method doesn't work, any idea? "Error TypeError: ratesData.find is not a function"
@ExcelGoogleSheets
@ExcelGoogleSheets Жыл бұрын
That typically means that you didn't get ratesData correctly in previous lines.
@pigeonworks8366
@pigeonworks8366 Жыл бұрын
Had same error. Turned out i had .getValues instead of .getValues()
@enriqueferolino7080
@enriqueferolino7080 Жыл бұрын
Amazing tutorial. Explained very well.. But how to vlookup the value if the column is reverse? for example my lookup value or criteria is in the J:J column then I want to lookup in column B:B. What would be the code of that? Thank you🙏🙏
@hollythyng6106
@hollythyng6106 Жыл бұрын
This is a great video. Well presented, and very easy to follow. Thank you! I've subscribed
@ExcelGoogleSheets
@ExcelGoogleSheets Жыл бұрын
👍
@mohsinkhan4232
@mohsinkhan4232 2 жыл бұрын
Hi Sir, In this video you used the Vlookup only one column if we pick the multiple columns then how to do this?
@koonerhospitalitygroup9688
@koonerhospitalitygroup9688 Жыл бұрын
Finally figured it out. Below gets to columns back. const matchSku = searchValues.map(searchRow => { const matchRow = srcdata.find(r => r[0] == searchRow[0]) {return matchRow ? [matchRow[4],matchRow[0]] : [[null],[null]]} }) and for the last line edit make sure that your .setValues(matchSku) is as wide as the range your getting
@denisbilo
@denisbilo Жыл бұрын
My god you're amazing! I was trying to do something particular. I have a spreadsheet where I have to associate an ID code in an automatic way. The script should make a research in bigquery and do a match of the name and the surname and then give me back the ID code associated with the person. Like a vlookup into BigQuery. Is that possible? Do you have a video about that? I've found nothing online...
@jaywilner4187
@jaywilner4187 2 жыл бұрын
thank you so much! this will help me at work doing lookups. is there a way to do a lookup not for the entire value but say a text string (return all values that match string "ali"?
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
Sure. I would suggest learning JavaScript String methods in order to understand how to do other types of matches, including contains.
@lpanebr
@lpanebr 2 жыл бұрын
I wonder which use case should this be better or if it has a performance benefit?
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
I wouldn't replace spreadsheet VLOOKUPs with this. This is necessary only when you have similar issues that you need done in scrips. Example: you have a Web App and you need to find matching price for product selected by the user.
@lpanebr
@lpanebr 2 жыл бұрын
@@ExcelGoogleSheets hmmm yes. I'm sure I have more than a couple places I'm using a mix of filter, map or for loops that could be simplified! Thanks!
@JuanJose-ik8gf
@JuanJose-ik8gf Жыл бұрын
Great video, I have tried to include a match inside the search to get for each row a different column but i could not do it, I hope you can make an extension of this tutorial with that option :) thanks,
@perooogaming
@perooogaming 2 жыл бұрын
Very informative.
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
Thank You!
@haustimp
@haustimp Жыл бұрын
This was amazing - thank you very much!
@Kevin_Cohen
@Kevin_Cohen 2 жыл бұрын
Amazing video, love these apps script videos!
@bigbrother1211
@bigbrother1211 2 жыл бұрын
Will definitely use it sometime, thanks!
@IvyPlans
@IvyPlans Жыл бұрын
Great explanation. Is there a way to automatically run the code without having to manually run the code. If not available, can it run with a button?
@guyoimano
@guyoimano Жыл бұрын
yes, you can put triggers on
@AxelAire-yh9qq
@AxelAire-yh9qq Жыл бұрын
Hello, very nice How to, and thank for help the comuunity :) But i don't have a find method, it's possible to share you'r library or what is you'r video to explain it ? :D Thk
@AxelAire-yh9qq
@AxelAire-yh9qq Жыл бұрын
function DOLOOKUP() { const ss = SpreadsheetApp.getActiveSpreadsheet() const ws= ss.getSheetByName("Test Drive") const wsData = ss.getSheetByName("Test Drive Result") const ratesData = wsData.getRange(6,3, wsData.getLastRow()-1,wsData.getLastColumn()-1).getValue() const searchValue = ws.getRange("F4").getValue() const matchRow = ratesData.find(r => r[0] == searchValue) console.log(matchRow) }
@ExcelGoogleSheets
@ExcelGoogleSheets Жыл бұрын
there is no library. so long as you are under V8 engine you can use find even if it doesn't show in autocomplete.
@muhamadekocahyono2661
@muhamadekocahyono2661 2 ай бұрын
Can we run it automatically?
@francoisprevot7067
@francoisprevot7067 2 жыл бұрын
How can i return nothing insteand of "null" with the match function ? By "nothing" i mean => If you don't have any match jump to the next one (don't earase data already in the cell). With your method the script remove data and replace with "blank cell". How can i change this to keep my data already in cell ?
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
If you remind me what the code was in this video I might be able to help you. Otherwise I don't remember 😀
@francoisprevot7067
@francoisprevot7067 2 жыл бұрын
@@ExcelGoogleSheets const ratesData = wsRates.getRange(9, 1, wsRates.getLastRow() - 1, 12).getValues(); const searchValues = wsSalesData.getRange("C2:C2041").getValues(); const matchingRates= searchValues.map( searchRow => { const matchRow = ratesData.find(r => r[0] == searchRow[0]) return match = matchRow ? [matchRow[7]] : [null] }); console.log(matchinRates) wsSalesData.getRange("O2:O2041").setValues(matchinRates) So my problem is on this line " return match = matchRow ? [matchRow[7]] : [null]" > If the match isn't find i don't want null that erase my datas. I want to keep it but i don't know if there is a simple way to do it or not. Also how can i setup a dynamical Rage for those : wsSalesData.getRange("O2:O2041") wsSalesData.getRange ("C2:C2041") (i don't want to run all rows every time the script run but only those where there is data)
@johnstevens4211
@johnstevens4211 2 жыл бұрын
@@ExcelGoogleSheets I have the same question, hope you can help. In the line const match = matchRow ? matchRow[2] : null , what do I need to change to keep the current cell value and not change it to null if no match is found. Thanks!
@chrishooks1714
@chrishooks1714 2 жыл бұрын
Same question as well. I don't want it to overwrite the data currently in the cell, here is the code similar to yours: const ss = SpreadsheetApp.getActiveSpreadsheet(); const wsPaymentData = ss.getSheetByName("Payments") const wsApprovedApps = ss.getSheetByName("Test") const paymentData = wsPaymentData.getRange(2,1,wsPaymentData.getLastRow()-1,4).getValues(); const searchValues = wsApprovedApps.getRange("C2:C1990").getValues(); const matchingPayments = searchValues.map(searchRow => { const matchrow = paymentData.find(r => r[0] == searchRow[0]) return matchrow ? [matchrow[1]] : [null] }) //console.log(matchingPayments) wsApprovedApps.getRange("J2:J1990").setValues(matchingPayments)
@chrishooks1714
@chrishooks1714 2 жыл бұрын
@@johnstevens4211 Figured it out!!! You have to merge the results from the existing data and the data your filtering. I created a const called existingpayment which gets the entry for that particular column on the original data. During the filter if no match is found instead return "null" return the existing value (in my case existingpayment). Hope this helps! function matchPayment(){ //Get data from each sheet const ss = SpreadsheetApp.getActiveSpreadsheet(); const wsPaymentData = ss.getSheetByName("Payments") const wsApprovedApps = ss.getSheetByName("Approved Applications") const paymentData = wsPaymentData.getRange(2,1,wsPaymentData.getLastRow()-1,4).getValues(); const searchValues = wsApprovedApps.getRange("C2:J1990").getValues(); const matchingPayments = searchValues.map(searchRow => { const existingpayment = searchRow[7]; //extract value from existing column J const matchRow = paymentData.find(r => r[0] == searchRow[0]); //console.log(matchingPayments); return matchRow ? [matchRow[1]] : [existingpayment] //If no match is found return existing entry from column J }) //console.log(matchrow); //console.log(matchingPayments) wsApprovedApps.getRange("J2:J1990").setValues(matchingPayments) }
@gdevelop9678
@gdevelop9678 2 жыл бұрын
This is so awesome and almost similar to what I've been struggling to do without success... Instead of populating the rate in all corresponding rows, how (which is what I'm trying to do) will you code it if it's a dropdownList in Sales Data sheet? I succeeded to modify your code to getValue from a dropdown selection and it works when I run the function from the script editor; but the onEdit fonction won't populate the corresponding value on dropdown selection... If you can please help with this... Again, thx...
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
I'm not sure where you're getting your data. For example onEdit simple trigger doesn't allow data coming from a different spreadsheet. Otherwise it should work if there are no restrictions. What's in your logs?
@anunayjallan
@anunayjallan Жыл бұрын
Thanks for the video! Is there any way in which we can copy the source formatting to the lookup cell?
@ExcelGoogleSheets
@ExcelGoogleSheets Жыл бұрын
There is but it would be really slow.
@gdevelop9678
@gdevelop9678 2 жыл бұрын
Thank you very much sir; I finally got it working with a drop down List as desired; :) :)
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
Excellent!
@Kaenshin
@Kaenshin Жыл бұрын
I was wondering if there is a way, so it will keep the previous data if won't find instead of NULLing it? 😄 Is there something to replace NULL so he skips it and don't update it? And only update those which he finds?
@Kaenshin
@Kaenshin Жыл бұрын
I guess, I did and it worked 🤔'return matchRow1 ? [matchRow1[3]] : [searchRow1[2]]'
@ExcelGoogleSheets
@ExcelGoogleSheets Жыл бұрын
👍
@martinsaldanokrogslund6238
@martinsaldanokrogslund6238 2 жыл бұрын
Really cool video, thanks a lot for uploading it!
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
:)
@mosintyagi5434
@mosintyagi5434 2 жыл бұрын
map function also not coming. please suggest for both
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
If map function is not showing then you made a mistake before that.
@robinnauli4891
@robinnauli4891 2 жыл бұрын
how to make it renewed every i edit it
@trandanhlong5659
@trandanhlong5659 2 жыл бұрын
Can you share your file in your video ?
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
gist.github.com/chicagocomputerclasses/b89812449243cb0d79229f4eebcd999a
@trandanhlong5659
@trandanhlong5659 2 жыл бұрын
@@ExcelGoogleSheets Thank you very much
@marcosrs75
@marcosrs75 2 жыл бұрын
man you're good
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
Thank You!
@Puner54
@Puner54 2 жыл бұрын
Teacher...some of your AppsScript work and some dont???
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
Not sure what you mean by "dont". Any particular examples of the ones that don't work?
@Puner54
@Puner54 2 жыл бұрын
@@ExcelGoogleSheets Teacher...I couldn't make either of the Timestamp Scripts work. Went through them with a Fine Toothed Comb too???
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
@@Puner54 Share the code you've tried, maybe we can help to spot the problem.
@Puner54
@Puner54 2 жыл бұрын
@@ExcelGoogleSheets Teacher...I'm not certain on how to "Share" the Code? Don't I need an Email Address to do so?
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
Paste it in comments
@GangaRam-bt7li
@GangaRam-bt7li 2 жыл бұрын
Please give solution to repeat selected rows on every print . Thanks
@learningtechie2964
@learningtechie2964 2 жыл бұрын
This guy never shares his codes :(
@ExcelGoogleSheets
@ExcelGoogleSheets 2 жыл бұрын
Yea, this guy sucks! Get him! :)
@Dfjjiii8btrdcvvbbhhhhhhhhh
@Dfjjiii8btrdcvvbbhhhhhhhhh Жыл бұрын
How can i contact you... Urgent?!!!!!
Google Sheets - Join Tables using VLOOKUP & QUERY Functions
16:53
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 45 М.
JavaScript Arrays - Programming Like a Grown Up - Google Sheets Apps Scripts - Array Methods Part 5
20:32
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 56 М.
ROLLING DOWN
00:20
Natan por Aí
Рет қаралды 9 МЛН
My Cheetos🍕PIZZA #cooking #shorts
00:43
BANKII
Рет қаралды 24 МЛН
Doing This Instead Of Studying.. 😳
00:12
Jojo Sim
Рет қаралды 32 МЛН
小丑把天使丢游泳池里#short #angel #clown
00:15
Super Beauty team
Рет қаралды 34 МЛН
How to Copy a Row to another Sheet with Google Apps Script
15:18
Google Sheets onEdit Timestamps, Everything about onEdit Function - Live Stream Recording
52:22
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 42 М.
✨ Google Sheets Introduces Tables
7:27
Dan Leeman
Рет қаралды 28 М.
JavaScript Filter Method Tutorial - Google Sheets Apps Scripts - Array Methods Part 7
27:19
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 71 М.
JavaScript Arrays & Map Method Tutorial - Google Apps Script Part 4
26:53
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 54 М.
Convert Google Sheets into a REST API
14:10
Better Sheets
Рет қаралды 6 М.
QUERY - Drop Down List to Filter Data - Google Sheets
15:25
Learn Google Sheets & Excel Spreadsheets
Рет қаралды 343 М.
Automatically Sort New Rows in Google Sheets
8:08
Prolific Oaktree
Рет қаралды 13 М.
ROLLING DOWN
00:20
Natan por Aí
Рет қаралды 9 МЛН