Multilevel Dependent Dropdown in Google Sheets (With Google Apps Script)

Поділитися
Вставка
  • Опубліковано 27 сер 2024
  • In this video we will learn how to create a cascade of n dependent dropdowns in Google Sheets. It will work on 2, 3, or how many you want, as long as they are in order, one after the other
    ➤You can find the template from this video in my patreon page, where you´ll also have priority responses to your questions
    practicalsheet...
    You can also join my academy practicalsheets.com, where you´ll find, not only the templates for this and all the videos, but also Google Sheets Courses, technical service, and more
    ➤You can also subscribe to the channel where you´ll find a new Sheets video every week.
    Here are some of the places where you can follow and support me:
    ➤Patreon: practicalsheet...
    ➤Webpage: practicalsheet...
    ➤Newsletter: practicalsheet...
    ➤Telegram: practicalsheet...
    ➤Facebook: practicalsheet...
    ➤Twitter: practicalsheet...
    Any suggestion, question or insights, feel free to comment below

КОМЕНТАРІ • 138

  • @practicalsheets
    @practicalsheets  Рік тому +1

    If you are having trouble when inserting lines replace the conditional witht his line
    if(activeSheet.getName()=="Dropdown" && activeRow>1 && activeCol>=3 && activeCol

  • @archive8650
    @archive8650 Рік тому +17

    I've been searching for this my whole life! You're a life saver!

    • @Simplykryss
      @Simplykryss Рік тому +1

      Are you having any issues with Line 3? I keep getting an error

    • @practicalsheets
      @practicalsheets  Рік тому

      Thanks for the words!

    • @practicalsheets
      @practicalsheets  Рік тому +1

      Can you share the error?

    • @Simplykryss
      @Simplykryss Рік тому +1

      @@practicalsheets I emailed you :) Looking forward to your reply! :)

    • @tajudinfreelancer
      @tajudinfreelancer Рік тому

      This is really incredible and very informative. Thanks

  • @brentcrittenden1110
    @brentcrittenden1110 Рік тому +4

    I've watched several videos on multilevel dependent dropdown lists and this is the first that worked out for me. I just completed this for an application I'm working on. Thanks.

  • @ariellin2440
    @ariellin2440 9 місяців тому +2

    Thank you so much for this video! This is the tutorial I used because it's explained so well. Starting from 18:18-18:55 you noted the problem of duplicate categories, but stated you would make another video about this issue in the future. I would really appreciate it if you could make an updated video addressing this problem (as well as the other problem of deleting). My spreadsheet and others could really use your help. Thank you!

  • @Saumil5
    @Saumil5 11 місяців тому +6

    I feel Google should come up with a better and quicker solution for it as this is a very common requirement in spreadsheets !
    Thanks for the tutorial , it is good !

    • @practicalsheets
      @practicalsheets  10 місяців тому +1

      You are right
      One of the main complaints from users that come from Excel is that doing dependent dropdown requires some work, whilest in Excel is much simpler
      Regards!

  • @scott.ballard
    @scott.ballard 7 місяців тому

    Excellent and thorough demonstration of how to accomplish this in App Script. Thanks for making the video!

  • @montplaisant8677
    @montplaisant8677 7 місяців тому +1

    Thank you so much. I have been looking for this in a while and it worked exactly like I wanted. Thanks a lot

  • @MrSnailspace
    @MrSnailspace Рік тому +1

    This worked perfectly and much less code than others I looked at. Just had to change my offset for my use. Thank you!

  • @CrazyAvocado-sm6vm
    @CrazyAvocado-sm6vm Рік тому +1

    Amazing lesson. Tried if for my fault codes dropdown list in engineering department work orders system, everything is working perfectly! Thank you very much!!!!

  • @tbudyka
    @tbudyka 3 місяці тому +1

    This is what I was looking for!

  • @abdullahquhtani4247
    @abdullahquhtani4247 Рік тому +4

    Great man 👍🏼. There’s one request I hope you consider, what if I want dependent drop-down goes vertically instead of horizontally.
    Thank you.

    • @practicalsheets
      @practicalsheets  Рік тому +3

      Excellent suggestion. It shouldn´t be that different. I´ll think about it and come back to you
      Regards!

  • @JoanneDiaz-mz1ks
    @JoanneDiaz-mz1ks 8 місяців тому

    Thanks so much! This is exactly what I needed. You bring joy to the world with your nerdiness. :)

  • @TinkerScribe-yq6xk
    @TinkerScribe-yq6xk 3 місяці тому +1

    I'm sorry for adding my implementation of the code in the comments. I understand that you want to drive traffic to your patreon.

    • @practicalsheets
      @practicalsheets  2 місяці тому +2

      No probl!
      I can't help if you want to share your codes.
      In the patreon I have to offer additional things like quick answers and variations over the basic templates
      Thanks anyway for the comment!
      Kind Regards

  • @itsgracehui
    @itsgracehui Рік тому +1

    THANK YOU! Been looking for SO long for a solution!!!

    • @practicalsheets
      @practicalsheets  Рік тому

      Thank you for the kind words
      Regards!

    • @itsgracehui
      @itsgracehui Рік тому +1

      @@practicalsheets Hi! I got it to work but I noticed that, the dependent dropdown only populates, when I click away into a different cell and then click into it again. Am i doing something wrong?

    • @practicalsheets
      @practicalsheets  Рік тому

      @@itsgracehui Hello! It should populate when you enter or select the new data. Does it not?

    • @practicalsheets
      @practicalsheets  Рік тому

      @Shaybel Roquial L. Algones Hello! Could I see your code? In my sheet it is working as soon you select from the main dropdown. Regards!

  • @mrvictorbassey
    @mrvictorbassey 9 місяців тому +2

    Thanks for making this, it really has been helpful. Also, I'd really appreciate your guidance on how to clear data in columns D, E, F once the option in column C is changed. Also clear only columns E, F when the value in column D is changed and so on.
    Thanks.

    • @practicalsheets
      @practicalsheets  8 місяців тому

      Excellent suggestion for part 2. It shouldn´t be complicated
      Regards!

  • @pumpernickel4429
    @pumpernickel4429 Рік тому +1

    This is awesome, thanks so much! I’m having a bit of trouble understanding the arrays bit and how to connect/reference the columns from the data sheet with/in the dropdown sheet.

    • @practicalsheets
      @practicalsheets  Рік тому

      Thanks for the words!
      Yeah, the array part is complicated at first
      Anything you need let me know
      Kind Regards

  • @cyrusazari5230
    @cyrusazari5230 Рік тому

    Huge help, accurate explanation, and fixed my issue! Liked and subscribed! ty again

  • @user-dr6hs8ft9z
    @user-dr6hs8ft9z Рік тому +2

    Hello. I have a doubt. Mine is working fine till 15:45. But when I do steps from 17:00, dropdown list is blank, why is that?

  • @reynssoria5944
    @reynssoria5944 7 місяців тому

    thank you so much, this is exactly what i need

  • @Elemer777
    @Elemer777 Рік тому +1

    Great video! :) I have a suggestion for your next video: How to scan QR codes and save the data in it to an spreadsheet. As far as I know Google Sheets can do it. I hope my suggestion help you.

    • @practicalsheets
      @practicalsheets  Рік тому

      Thanks for the suggestion! I´ll look for it! Regards!

  • @paulkirby-smith4891
    @paulkirby-smith4891 Рік тому

    Great video,
    I am working on a free to use tool for people to use to create a budget, track spending, and plan savings as well as getting out of debt. I have managed to get my first catagory done although I am strugling to setup a sub catagory would apprecaite a conversation to better understand building this.

  • @StefanHielscher-gw8oj
    @StefanHielscher-gw8oj 3 місяці тому +1

    This is fantastic! Is there any simple way to prevent users from manually inputing data in columns D, E and F (i.e. not coming from the gradual building of dropdowns starting with column C)?

    • @practicalsheets
      @practicalsheets  3 місяці тому

      Very interesting
      Maybe you could try by putting an impossible data validation in these columns, say "Text contains "hjkkdsfhjkshdfhsdkf""
      Once the dropdown is selected it will remove this data only for that row and create the dropdown (I hope)
      Kind Regards

    • @StefanHielscher-gw8oj
      @StefanHielscher-gw8oj 3 місяці тому +1

      @@practicalsheets Yeah that actually works, awesome!

    • @practicalsheets
      @practicalsheets  3 місяці тому

      @@StefanHielscher-gw8oj Excellent!

  • @drizzleshard903
    @drizzleshard903 Рік тому +1

    I thought everything worked fine, but I see now I seem to have 1 issue with the script, not sure how to solve it.
    I have 3 columns with dropdown lists. The first has 3 unique values. Then in my second list some values are the same, just as you have in your 3rd list (for example, you have Functions for Google > Sheets, as well as for Microsoft Office > Excel). Somehow when I select a value in my 2nd dropdown list, the dropdown in the last column just gives ALL values, instead of only the ones that need to show. Not sure if it makes sense what I'm explaining..

    • @drizzleshard903
      @drizzleshard903 Рік тому

      So I am getting the appropriate dropdown for the second column which is dependent upon the first, but for the 3rd column, it is showing me a dropdown dependent upon the second one only and not first and second one both.

  • @lholhofox
    @lholhofox 11 місяців тому +1

    Thank you very much!!

  • @SantiagoCardozo
    @SantiagoCardozo Рік тому

    Man, I'm trying to apply the array to my sheets, but I haven't figured it out.
    My dropdown starts in U (21) Column, a and my Data is just like yours, Suite starts in A.
    I'm código the arrange like this
    var=list.data.filter(row=>row[activecol-21]==activeValue).map(row=>row[activeCol-22])
    This is not working, I hope you can help me

  • @michelmenega
    @michelmenega Рік тому +1

    Wow, thanks a ton! This video really helped me out. Do you happen to know if it's possible to format the dropdown as a "chip style" using App Script?

    • @practicalsheets
      @practicalsheets  Рік тому +1

      Good question
      I´m not sure, given that it is so new
      I looked around and I don´t see it
      I´ll keep looking
      Regards!

  • @Friendly.Friend
    @Friendly.Friend 5 місяців тому +1

    I chatted with you in FB about my error, please see it and help me, because I tried many ways but no effected. Thank you for your help!

    • @practicalsheets
      @practicalsheets  5 місяців тому

      Hi! Please you can write to practical.sheets@gmail.com instead
      Regards!

  • @juergenwilliams515
    @juergenwilliams515 5 місяців тому +1

    hey, thank you for the information in this video it is helpful so far. I am running into a bit of a speed.
    TypeError: Cannot read properties of null (reading 'getDataRange')
    at dropdown(Code:11:26)
    at onEdit(Code:20:3)

    • @practicalsheets
      @practicalsheets  4 місяці тому

      Normally when this happen you may have a problem with your sheet. Maybe the name was spelled wrong
      Kind Regards

  • @smarkow10
    @smarkow10 Рік тому +1

    Love the script and the video. I know it has been asked before, but any progress or suggestions on vertical vs horizontal. I tried changing the offset from 0,1 to 1,0, and it seems to work for the first dropdown, but then the next is just blank. It seems like it should be easy, but it does not work. Thanks.

    • @practicalsheets
      @practicalsheets  Рік тому

      Thank you!
      What do you mean by vertical vs horizontal
      Regards!

    • @smarkow10
      @smarkow10 Рік тому

      @@practicalsheets
      You say as long as the sheet with the dropdowns are one next to each other and that the order corresponds to the order in the data table. For instance, you use the following:
      DATA Sheet
      1 2 3 4
      1 Suite Tool Category Subcategory
      2
      DROPDOWN Sheet
      1 2 3 4 5 6
      1 Email, Name Suite Tool Category Subcategory
      2
      So your multiple dropdowns are one next to the other going horizontally.
      What I was asking, and some others had asked, was having the dropdown sheet look like this:
      1 2 3
      1 Email, Name Suite
      2 Tool
      3 Category
      4 Subcategory
      But I found the solution. The reason it would not work is that the first dropdown (Suite) looks to the Suite column in Data, so this works fine for horizontal or vertical. (meaning R1C1(Data) corresponds to R1C3(dropdown), so Suite to Suite.
      But for the next iteration if going horizontally, now R1C2(Data) corresponds to R1C4(dropdown), R1C3 to R1C5, etc, so Tool to Tool, Category to Category, etc. But if you move down vertically you get R2C2(Data) corresponding to R2C3(dropdown) so Tool to Suite. The row doesn't matter, but there are now no matches because data in looking in the tool column to match the suite column. You need R2C2 to correspond to R2C4. This continues each time you move downward. (R3C3 to R3C5, etc). So after the line:
      var data=spreadsheet.getDataRange().getValues()
      I added the following:
      if (activeRow>=2){ //if on the second iteration onward
      activeCol=activeRow+2 //so R2 would be C4, R3 would be C5, etc
      }
      And you just change the line offset for setDataValidation(validation) to 1,0 instead of 0,1.
      I made my own specific sheet when coming up with this, so did not do this with your exact code and data, so I don't know if I missed anything, but if you add this to your code it should work.

  • @SerenaCook-vk5mf
    @SerenaCook-vk5mf Рік тому +1

    Thanks for this, really helpful. However, when I add a new row above or below the formula has an error, is there a way to fix this?

    • @practicalsheets
      @practicalsheets  Рік тому

      Hello!
      Do you mean when you add a row in the dropdown sheet? or in the lists of values?
      Regards!

  • @SandeepKumar-vi3tg
    @SandeepKumar-vi3tg Рік тому +1

    Thanks for your help
    Please also help in to clear content when data is delete or modify at every level.
    Please

    • @SandeepKumar-vi3tg
      @SandeepKumar-vi3tg Рік тому +1

      @Practical Sheets

    • @practicalsheets
      @practicalsheets  Рік тому

      I will work on part 2
      Regrds!

    • @stanleypaul1381
      @stanleypaul1381 Рік тому +1

      @@practicalsheets Need this very much. Will it be availble here soon or sooner in Patreon?

    • @practicalsheets
      @practicalsheets  Рік тому +1

      @@stanleypaul1381 Hello!
      Ill work on it, and make it available next week in patreon if i can
      Regards!

  • @ericguild4732
    @ericguild4732 Рік тому +1

    I am trying to have a check box in sheet1!C12:C162 prompt 1 of 2 drop down lists in sheet1!F12:F162. I need the same format for an additional 12 sheets. 1 for every month. Any suggestions?

    • @practicalsheets
      @practicalsheets  Рік тому

      Hello
      The two dropdowns are the same for all 12 months
      I recommend using a more simpler code or formula. Here are 2 videos that may help
      ua-cam.com/video/uuC24mFV8CY/v-deo.html
      ua-cam.com/video/Wb8aMIL0Idw/v-deo.html
      Regards!

  • @neteller617
    @neteller617 Рік тому +1

    Thanks for this video

  • @Hellgate-ub5of
    @Hellgate-ub5of 6 місяців тому

    My Last Column when i filtered but it shows all uniq data values, not only the particular one's, show's not relevant to that one also,please advise

  • @dollsizedpistol1
    @dollsizedpistol1 Рік тому +2

    Hello, Practical Sheets! Thank you so much for this video! I am trying to use this script for just one dependent dropdown list. Right now it is working so that the dependent dropdown appears, but it is blank, nothing in the list. Do you have any recommended troubleshooting actions?
    I've read over and tinkered with the code a lot and I haven't been able to figure why I'm not getting that second list for the dropdown.
    Thank you for your help!

    • @dollsizedpistol1
      @dollsizedpistol1 Рік тому +1

      I just figured it out!! I was missing a word!! :) This is such an awesome script, thank you so much!!! Just subscribed to your Patreon :)

    • @dollsizedpistol1
      @dollsizedpistol1 Рік тому +1

      Okay, I'm having another problem now. I am using this script in a spreadsheet/workbook with multiple tabs, and it's running in every single tab, instead of just the tab that I refer to in the code. Why is that happening??

    • @dollsizedpistol1
      @dollsizedpistol1 Рік тому +1

      figured this one out too. :)

    • @practicalsheets
      @practicalsheets  Рік тому

      You don´t need me at all ;)
      This thread act as a reflection and a testament of how you figure things out! Congrats
      PS. Sorry for getting back so late. You can write in the patreon forum
      Regards!

  • @user-rx5to2cl4g
    @user-rx5to2cl4g 9 місяців тому

    Love this one, thanks for teaching and sharing! As for my case when I applied the code to my own data, I could get all of the data range when looking at the Execution log however I do not get the wanted filtered data. It shows nothing inside the bracket (Info [ ] ). Any idea why the filter function did not return any results?

    • @user-rx5to2cl4g
      @user-rx5to2cl4g 9 місяців тому

      Just figured it out after reading all the previous comments/answers in here so this is the code I wrote "var list= data.filter(row=>[0]==activeValue).map(row=>row[1]) - The code did not work because I missed to write "row" before [0] - So the whole exact code should be then var list= data.filter(row=>row[0]==activeValue).map(row=>row[1]). Been stuck for two days and looking around the internet/google on what might be the error but no satisfying results so came back again to this video and read all the existing comments and found out that we have to pay attention to each single element we write 😁

  • @Shnoogs
    @Shnoogs Рік тому +1

    Thanks man!
    i get this message:
    Exception: The parameters (number) don't match the method signature for SpreadsheetApp.Range.offset.
    at dropdown(Code:14:16)
    at onEdit(Code:22:3)
    im using a Right-to-Left sheets (its in hebrew).. what am i doing wrong?

  • @pntnhanJOC
    @pntnhanJOC Рік тому

    Thank you so much!

  • @filipesantos2424
    @filipesantos2424 Рік тому +1

    Hey, how's it going? Dude please help me. The function: =SUMIF(B:B;">=1.76") will sum only the values ​​greater than or equal to 1.76 from column "B".
    But instead of adding I wanted to MULTIPLY. How do I do this?

    • @practicalsheets
      @practicalsheets  Рік тому

      Hello
      Here you can use SUMPRODUCT
      I´ll try to do a video soon
      Regards!

  • @user-ll6sb3pq5s
    @user-ll6sb3pq5s Рік тому

    I have been getting the appropriate dropdown for the second column which is "Manufacture" dependent upon the "Parameter" but for the "Pack Size" it is showing me a dropdown dependent upon the Manufacturer only and not Parameter and Manufacturer both.

    • @drizzleshard903
      @drizzleshard903 Рік тому

      I seem to have the same issue. Were you able to solve it?

  • @rebecaklein3022
    @rebecaklein3022 10 місяців тому +1

    If I set this script to my template tab, how can I get it to run on other tabs within the same spreadsheet when I make a copy of the template? I'm thinking I could set the script to work on Active Sheet but I'm not sure where to indicate that on the script. Thanks

    • @practicalsheets
      @practicalsheets  10 місяців тому +2

      Hello!
      One option would be to remove this part of the code
      activeSheet.getName()=="Dropdown"
      However you should be careful because this will make it work in all of your sheets
      Regards!

    • @Angie-lf7h
      @Angie-lf7h 10 місяців тому +2

      @@practicalsheets I think this is the exact problem I'm having! (Disclaimer, I know nothing about App Script and I just copied what you were typing but I was able to figure out how to tweaks to make it work on my spreadsheet.) I need to apply this to several sheets. So I thought I'd just copy and past the same script below the original one and update the name of the sheet accordingly. But only one spreadsheet worked. Now that I see this comment, I removed the line you indicated above and now it works on all the sheets. Is there a way to make it work on some but not all sheets?

    • @practicalsheets
      @practicalsheets  10 місяців тому +2

      @@Angie-lf7h I am working on a video to address this. Stay tuned the next couple of weeks! Regards!

  • @bsc169
    @bsc169 Рік тому +1

    Thanks

  • @DehnerDeLeon
    @DehnerDeLeon 11 місяців тому

    I have problems running this now (it kept the 4th column blank) is it because on the data validation criteria, the "list" was replaced with "dropdown (from a range)"? An update on this would be great! Let me know how to solve this it can be an update on line 12 | var list=data.filter(row=>row[activeCol-3]==activeValue).map (row=>row[activeCol-2])

  • @morpheus7550
    @morpheus7550 Рік тому +1

    May I know how you color an entire row based on the selected dropdown list?

    • @practicalsheets
      @practicalsheets  Рік тому

      The easiest way would be to use conditional formatting. I could do a video if you want
      Regards!

  • @terrysun2683
    @terrysun2683 Рік тому +1

    I just followed your steps, but i found when i add more Rows at the bottom, the dropdown ended from Column F to G, could you please help! Thanks!

    • @practicalsheets
      @practicalsheets  Рік тому +1

      Hello!
      Do you mean rows in the Data? or in the Dropdown sheet?
      Regards!

    • @terrysun2683
      @terrysun2683 Рік тому +1

      @@practicalsheets Thanks for the reply! Rows in the dropdown sheet

    • @practicalsheets
      @practicalsheets  Рік тому

      @@terrysun2683 Hello
      I think I don´t fully understand you
      You mean that in the new rows added you only have dropdowns up to G?
      Regards!

    • @dianachemutai3391
      @dianachemutai3391 10 місяців тому

      I'm having the same problem when I add rows in the dropdown sheet, kindly help

  • @Simplykryss
    @Simplykryss Рік тому +1

    Hi!! Thanks so much for this video! Im hoping you can help me. I am at the part of the video where you are testing "Toast" and mine doesnt show up :( The error I keep getting is "TypeError: Cannot read property 'getRow' of null dropdown @ Code.gs:3". Any ideas why?

  • @harshdeepsingh8486
    @harshdeepsingh8486 11 місяців тому

    I have more than 500 values in the dependent dropdown. and Data validation has a limit of 500 values . Is there any possible way to make it dependent dropdown.If so please revert ASAP.

  • @dillonmears6696
    @dillonmears6696 Рік тому

    Thanks for the great video! Would you happen to have any suggestions on how to get this to work for verticle data? Ex) Level 1 Dropdowns A1:B1 (Google, Microsoft Office), Level 2 Dropdowns A2:A4 (Sheets, Forms, Docs), and B2:B4 (Excel, Teams, Word). I have tried playing around with the code, but have not had any luck. I was able to get your code to work by creating a helper sheet that transposes my data, but I am trying to find a better solution that doesn't require the helper sheet. Thanks in advance! Have a great day.

    • @practicalsheets
      @practicalsheets  Рік тому +1

      Hello!
      I´m not sure if it can be done
      I will leave it as a second video, if I make it, ;)
      Regards!

  • @matteopallomo4888
    @matteopallomo4888 Рік тому

    I get the following errro: ReferenceError: row is not defined
    at dropdown(main:22:29)
    at onEdit(main:35:3)
    Can someone please help me?

  • @drizzleshard903
    @drizzleshard903 Рік тому

    Great video, thanks! Is it possible to let this script work for multiple tabs in one Google sheet?

    • @drizzleshard903
      @drizzleshard903 Рік тому

      I found the answer in one of the comments here, thanks!

  • @Angie-lf7h
    @Angie-lf7h 10 місяців тому +1

    Is there a way to have this work on multiple sheets (but not all)?

    • @practicalsheets
      @practicalsheets  10 місяців тому +1

      Yes! I´m working on a tutorial on this subject
      Regards!

    • @Angie-lf7h
      @Angie-lf7h 10 місяців тому +1

      @@practicalsheets thank you so much!

  • @JoanneDiaz-mz1ks
    @JoanneDiaz-mz1ks 8 місяців тому

    Were good statement doesn't appear on my end huhuhu

  • @D_Riz
    @D_Riz Рік тому +1

    I've just tried your tutorial but it says that the register result is too big): I can't get past it

  • @stanleypaul1381
    @stanleypaul1381 Рік тому +1

    How can I apply this to multiple worksheets?

    • @practicalsheets
      @practicalsheets  Рік тому +2

      Hello!
      If it´s in the same order in every sheet
      Just change this line
      if(activeSheet.getName()=="Dropdown" && activeRow>1 && activeCol>=3 && activeCol 1 && activeCol>=3 && activeCol

  • @khalidalluhybi483
    @khalidalluhybi483 11 місяців тому +1

    Hi . Your Patreon link doesn’t work ..

    • @practicalsheets
      @practicalsheets  10 місяців тому

      Finally I fixed it!
      Thanks for noticing ande letting me know
      Regards!

  • @mahersaan8722
    @mahersaan8722 Рік тому

    Not Working properly

  • @johncipolla8335
    @johncipolla8335 7 місяців тому

    challenge. do this with no code

  • @erikaknollenberg7526
    @erikaknollenberg7526 Рік тому

    I'm loving this script. Thank you. I've edited it to happen onOpen and to view each row for a value that's already set. Then, depending on its predefined value, it sets the dropdown for the respective cell. The only problem there are about 550 lines and it only gets to about 200 before timing out. How would you adjust this code to make it faster?
    function onOpen() {
    dropdown();
    }
    function dropdown() {
    // var activeValue = "CD";
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var discovery = ss.getSheetByName("DISCOVERY");
    var lastRow = discovery.getLastRow();
    //The Loop
    for (var i = 3; i row[0]==dropValue).map(row=>row[1]);
    var validation = SpreadsheetApp.newDataValidation().requireValueInList(list).setAllowInvalid(false).build();
    var discovery = ss.getSheetByName("DISCOVERY");
    discovery.getRange(i,6).setDataValidation(validation);
    } else {continue;}
    } catch(error) {continue;}
    }
    }

  • @karinab5593
    @karinab5593 Рік тому +1

    I keep getting an error and cant figure out what it could be. This is the code I used, my onEdit() is set up separately. The sheet where my dropdowns are located is called 'Active' (column 6-8 and row 3 - row 1 & 2 have header info) and the data sheet is called 'Org Leader Config.' (column 1, row 2):
    function DependentDrop() {
    var activeCell=SpreadsheetApp.getActiveRange();
    var activeRow=activeCell.getRow()
    var activeCol=activeCell.getColumn()
    var activeValue=activeCell.getValue()
    var activeSheet=activeCell.getSheet()
    if(activeSheet.getName()=="Active" && activeRow>2 && activeCol>=6 && activeCol row[activeCol-6]==activeValue).map(row=>row[activeCol-5])
    var validation=SpreadsheetApp.newDataValidation().requireValueInList(list).setAllowInvalid(false).build()
    activeCell.offset(0,1).setDataValidation(validation)
    }
    }
    I am getting the following error:
    Error TypeError: Cannot read properties of null (reading 'getSheetByName')
    at DependentDrop(DependentDrop:10:31)
    at onEdit(Code:9:3)
    I'm at a loss on where I messed up. Thanks!

    • @practicalsheets
      @practicalsheets  Рік тому

      Hello!
      Remove the toast part here
      var worksheet=SpreadsheetApp.getActiveSpreadsheet().toast("Pulling Staff Lists...");
      Regards!

    • @karinab5593
      @karinab5593 Рік тому +1

      @@practicalsheets I tried that, script now looks like:
      function DependentDrop() {
      var activeCell=SpreadsheetApp.getActiveRange();
      var activeRow=activeCell.getRow()
      var activeCol=activeCell.getColumn()
      var activeValue=activeCell.getValue()
      var activeSheet=activeCell.getSheet()
      if(activeSheet.getName()=="Active Reqs and Progress" && activeRow>2 && activeCol>=6 && activeCol row[activeCol-6]==activeValue).map(row=>row[activeCol-5])
      var validation=SpreadsheetApp.newDataValidation().requireValueInList(list).setAllowInvalid(false).build()
      activeCell.offset(0,1).setDataValidation(validation)
      }
      }
      I'm getting this error now:
      Exception: Please select an active sheet first.
      DependentDrop @ DependentDrop.gs:2

    • @practicalsheets
      @practicalsheets  Рік тому

      @@karinab5593 Hello
      When you say you "set up separately", is that your code is not within the Sheet
      This is where the problem may be
      Regards!

    • @karinab5593
      @karinab5593 Рік тому +1

      @@practicalsheets I have separate sections for each of the scripts I'm running.
      This is the Code.gs file
      function onEdit()
      { NewCopyRow(); //run 1st
      MoveHires(); // run 2nd
      MovePauseCancel(); // run 3rd
      DependentDrop(); //run 4th
      }
      Then I have a XX.gs file for each functions above. Not sure if that makes sense

    • @practicalsheets
      @practicalsheets  Рік тому

      @@karinab5593 You mean a library?
      You should separate this part
      var activeCell=SpreadsheetApp.getActiveRange();
      LEave it in the code of your sheet and then add it as an argument to your DepentDrop function
      Regards!

  • @HuongDo-qo5bj
    @HuongDo-qo5bj Рік тому +1

    Thank you so much for the very useful video!
    But my code doesnt work:
    function dropdown() {
    var activeCell=SpreadsheetApp.getActiveRange();
    var activeRow=activeCell.getRow()
    var activeCol=activeCell.getColumn()
    var activeValue=activeCell.getValue()
    var activeSheet=activeCell.getSheet()
    if(activeSheet.getName()=="Jan" && activeRow>4 && activeCol>=1 && activeColrow[activeCol-3]==activeValue).map(row=>row[activeCol-2])
    var validation=SpreadsheetApp=newDataValidation().requireValueInList(list).setAllowInvalid(false).build()
    activeCell.offset(0,1).setDataValidation(validation)
    }
    }
    function onEdit() {
    dropdown()
    }
    Errors:
    TypeError: activeCell.getRow is not a function
    at dropdown(Code:3:28)
    at onEdit(Code:15:3)
    TypeError: data.filter is not a function
    at dropdown(Code:12:19)
    at onEdit(Code:19:3)
    ReferenceError: SpeadsheetApp is not defined
    at dropdown(Code:9:5)
    at onEdit(Code:14:3)
    Could you pls help me point out sth wrong here? Thanks alot.

    • @practicalsheets
      @practicalsheets  Рік тому +1

      I found one error
      var data=spreadsheet.getDataRange().getValue();
      It is getValues()
      Regards!

    • @HuongDo-qo5bj
      @HuongDo-qo5bj Рік тому +1

      @@practicalsheets Thanks teacher, now it works!

  • @gerygg83
    @gerygg83 Рік тому

    Hi! Thanks a lot for this! For some reason I cannot get it to work, what am I missing? Should I activate this script somewhere? My file is as yours but nothing happens. Maybe I have notifications disabled? This is my code:
    function dropdown() {
    var activeCell=SpreadsheetApp.getActiveRange();
    var activeRow=activeCell.getRow()
    var activeCol=activeCell.getColumn()
    var activeValue=activeCell.getValue()
    var activeSheet=activeCell.getSheet()
    if(activeSheet.getName()=="Dropdown" && activeRow>1 && activeCol==3){
    SpreadsheetApp.getActiveSpreadsheet().toast("Were good")
    }
    }
    function onEdit(){
    dropdown()
    }
    Thanks!!

    • @practicalsheets
      @practicalsheets  Рік тому

      Add this
      if(activeSheet.getName()=="Dropdown" && activeRow>1 && activeCol==3){
      SpreadsheetApp.getActiveSpreadsheet().toast("Were good")
      Logger.log("It´s working")
      }
      And execute from the editor
      Regards!

  • @MariaMiranda-om2lj
    @MariaMiranda-om2lj Рік тому

    Amazing video! But I can't get my code to work :( I keep getting this error. Any advice on how to fix?
    TypeError: ws.getSheetbyName is not a function
    at dropdown(Code:10:15)
    at onEdit(Code:20:3)

    • @practicalsheets
      @practicalsheets  Рік тому

      Hello!
      Be careful with upper and lower case
      getSheetByName
      Regards!

    • @MariaMiranda-om2lj
      @MariaMiranda-om2lj Рік тому +1

      @@practicalsheets Yes... after hours of staring, and trying everything, that was the issue hahaha. Thanks so much!

    • @practicalsheets
      @practicalsheets  Рік тому

      @@MariaMiranda-om2lj Been there. sometimes just a coma costs hours and hours
      But it is very gratifying to solve it, even if it is trivial
      Finding errors and debugging is a whole science
      Regards!

  • @user-so9gj7fd5f
    @user-so9gj7fd5f Рік тому

    not working even I try to copy your code and sheet but no results at first it show me a error (please select an active sheet first. -code.gs:2) I'm Stuck here I'm very new in this. please anyone can help me? 🥲🥲