Supercharge Google Sheets with Dependent Dropdowns - Apps Script

แชร์
ฝัง
  • เผยแพร่เมื่อ 17 พ.ย. 2024

ความคิดเห็น • 28

  • @GodfreyMpala-c4f
    @GodfreyMpala-c4f 2 หลายเดือนก่อน +1

    🙌 Great tutorial!

    • @SheetsNinja
      @SheetsNinja  2 หลายเดือนก่อน

      So glad this was helpful!

  • @darroldwilliams5867
    @darroldwilliams5867 6 วันที่ผ่านมา

    I like the tutorial. How do you get the dropdowns to work in a different column? (column E, for example)

    • @SheetsNinja
      @SheetsNinja  4 วันที่ผ่านมา

      So in the script, I use this line to add the dropdown:
      sheet.getRange(row,col+1).setDataValidation(rule);
      You would modify the "+1" to get to the column you need. So for example, if your main option is in column A, and you want the conditional dropdown in E, then you would do this:
      sheet.getRange(row,col+4).setDataValidation(rule);
      Or if the dependent dropdown was actually before the main column, you can do that as well, just flip the + to a - and you can do it that way as well.

    • @darroldwilliams5867
      @darroldwilliams5867 4 วันที่ผ่านมา

      @@SheetsNinja I apologize for not being clear enough. I meant that the main option would be in column E, and the conditional dropdown would be in column F (or whatever column you choose).

    • @SheetsNinja
      @SheetsNinja  4 วันที่ผ่านมา

      @@darroldwilliams5867
      So in the first version, we have a line like this:
      if (source.getName() == 'DATA' && val != '' && col ==1) {
      You would just need to change the "col == 1" to be whatever column you want to watch (e.g. E in your case), so that would mean it would then look like:
      if (source.getName() == 'DATA' && val != '' && col ==5) {
      And then if you're looking in E and applying to F, then your .setDataValidation(rule) would only be "col+1" since it's still just the next column over.

    • @darroldwilliams5867
      @darroldwilliams5867 4 วันที่ผ่านมา

      @@SheetsNinja You are a lifesaver. However, I had a curveball thrown my way. The sheet needs two sets of dependent dropdowns. How would i get the second set of dropdowns to clear? (e.g. main (E) > dependent (F) space (G) main2 (H) > dependent2 (i)

    • @SheetsNinja
      @SheetsNinja  4 วันที่ผ่านมา

      @@darroldwilliams5867 So in this case you would need to take the whole if statement (from the first { bracket to the last }), duplicate it, and then just change the "col" references to the appropriate column.

  • @superbhatnagars
    @superbhatnagars ปีที่แล้ว

    Thank you so much Man you saved my day. That's really wonderful.

    • @SheetsNinja
      @SheetsNinja  ปีที่แล้ว

      Awesome, glad the video was helpful!

  • @bradprestbo1734
    @bradprestbo1734 2 ปีที่แล้ว

    Great tutorial, thank you!

  • @paredesrobert53
    @paredesrobert53 ปีที่แล้ว

    Can’t seem to get it quite right. Any chance you can take a look at test sheet I creat?

  • @Hazexotica
    @Hazexotica ปีที่แล้ว

    How can I move a data that the script reads on a dynamic drop down from one column to another column to validate correctly?

    • @SheetsNinja
      @SheetsNinja  ปีที่แล้ว

      I'm sorry, I'm not quite sure what you mean.

  • @zex7876
    @zex7876 3 หลายเดือนก่อน

    Is it possible to automatically clear DataValidation on Dependent dropdown when the parent dropdown is deleted?

    • @SheetsNinja
      @SheetsNinja  2 หลายเดือนก่อน

      I've done that before. Typically I will use an if statement to determine when this happens. Let's say the parent dropdown is in column 2 (B) and the dependent dropdown in column 3 (C):
      if (col == 2 && val == '') {
      sheet.getRange(row,3).clearDataValidations()
      }
      That will reset the dependent data validation when you clear out the data in column 2.

  • @MikalSimms
    @MikalSimms ปีที่แล้ว

    Is it possible to move the row to a different workbook instead of a different tab??

    • @SheetsNinja
      @SheetsNinja  ปีที่แล้ว

      Yes, you just have to specify the different spreadsheet in the script.
      E.g.
      let targetSS = SpreadsheetApp.openById("SheetId");
      let targetSheet = targetSS.getSheetByName("TargetTab");

  • @JessicaMartinez-yn1rd
    @JessicaMartinez-yn1rd ปีที่แล้ว

    I'm not sure why I keep getting an error about the undefined e.range even after setting the trigger, is there another step I need to take?

    • @SheetsNinja
      @SheetsNinja  ปีที่แล้ว

      So once you've authorized the script, it won't do anything if you try to run it from the editor except give an error. Next you'll want to test it on the sheet, and if it isn't working, make sure the tab name and column numbers are correct in your script.

    • @Fer_IH
      @Fer_IH ปีที่แล้ว

      Hopefully my answer is still on time 😅 that happens because you are you are running the code from the script, when it's supposed to do it when you are editing the spreadsheet.
      So that's the solution, don't run the script and check that the trigger is set when editing

  • @forcenick
    @forcenick 2 ปีที่แล้ว

    Great video! it's possible to do this without scripts too

    • @SheetsNinja
      @SheetsNinja  2 ปีที่แล้ว +1

      Yes, I know, I did a tutorial on a cool trick to be able to quick do dependent dropdowns without scripts here: th-cam.com/video/My1jJA-9K80/w-d-xo.html

  • @ophello
    @ophello ปีที่แล้ว

    It's aggravating that Google Sheets doesn't have a built-in method for this in their formulas that doesn't depend on either scripts or hidden rows / sheets.

    • @SheetsNinja
      @SheetsNinja  ปีที่แล้ว

      Yes, that is annoying. Maybe someday they will allow you to use formulas to populate a dropdown and this video will become obsolete.

  • @AM-jw1lo
    @AM-jw1lo 10 หลายเดือนก่อน

    I have worked on this and find that you don't show an entire view of the code. Since you don't have a download either, you have made this a laborious video to watch. There is a lot going on here and the smallest mistake take considerable time to troubleshoot. Do all your video's do this? Makes me consider not finding out.

    • @SheetsNinja
      @SheetsNinja  10 หลายเดือนก่อน

      I'm sorry you're finding this concept difficult, but I actually do show all the code as I build the whole thing in the video. If you're struggling with this, I would recommend checking out other videos on apps script and getting more familiar with the concepts.
      I did just add a link to make a copy of the source file, hopefully that helps you with the errors you're experiencing.