Ok first time using google sheets. I have made a data validation list .I know I can do Not in list in excel but how do I do it in google sheets. So the user can enter data and it gets saved back to list. I have my data validation set up so it accepts other text but I dont know how to add it to the list.
1 Answer
Although a Google Script can achieve what you're looking for where a user can simply have an option to enter a string of text on an alert box and it gets added to data validation list, a more straight forward approach is to use your source of data in data validation as "Range" of a section of your main Sheet or have it located on a different sheet. That way, any items listed on your range will be part of the Data Validation and users can simply add more items to the empty cells defined on your data validation range.
Quick Edit You can also try a simple script below that prompts user to input something they want to add to the dropdown list. You may refer to this documentation for the specifics.
function Additem() {
var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Database"); //Defined the sheet where to make edits
var lastrow = ss.getLastRow(); //Defines the last item on row with content
var targetcell = ss.getRange(lastrow+1,1); //Select whatever the next available blank row on column A to add entry to data validation
//UI Prompt for Adding Values
var sui = SpreadsheetApp.getUi();
var theprompt = sui.prompt("Add item to selection", sui.ButtonSet.OK_CANCEL);
var usersinput = theprompt.getResponseText();
Logger.log(usersinput)
//Conditional action for the UI
if (theprompt.getSelectedButton() == sui.Button.OK) {
targetcell.setValue(usersinput);
} else SpreadsheetApp.getActiveSpreadsheet().toast("Adding to drop down list cancelled","Notification");
}
This assumes that your sheet where you store your data is named Database (You can always change that part on the code. And what this does is add whatever was input on the prompt to the next empty cell on Column A1.
See samples below:
After entering any value on the prompt:


