skip to Main Content

I have a google sheet and one of the columns contains a dropdown list where users can select one of the values present on the list. For example the column name is "Duration" and users can select either 10, 20 or 30 from the dropdown list. At the moment users also have the ability to input their own value but I want to create a data validation rule that states a user must only select from the drop down list and show some sort of error message if the value is different from the values present in the list.

There is a google apps script running in the back but I am not too familiar with it and I am also not too familiar with google apps script in general.

2

Answers


  1. If I understood your question correctly, you should be able to achieve what you are after by using the standard Validation Rules available in Google Sheets.
    Screenshot

    Input the values, check the "Show help text for a selected cell" option. Here you can customize your help text. Make sure "Reject the input" is selected. Then click "Done".

    Not sure what script is running in the background or how that affects things without a more thorough explanation, so let me know if you are trying to achieve something else or if a script is causing a conflict with this process (for example, if the dropdown is being populated by the script).

    Login or Signup to reply.
  2. function myfunk2() {
      const ss = SpreadsheetApp.getActive();
      const sh = ss.getSheetByName("Sheet0");
      let r = SpreadsheetApp.newDataValidation().requireValueInList([10,20,30]);
      sh.getRange(1,1,10).setDataValidation(r);
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search