Last active
June 27, 2023 15:37
-
-
Save sschwartzman/ed34dec66231acd9092051170d0ed6dc to your computer and use it in GitHub Desktop.
Create a Multi-Select Drop-Down for any cell in Google Sheets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const separator = ', '; | |
const dvType = SpreadsheetApp.DataValidationCriteria.VALUE_IN_RANGE; | |
function onEdit(e) { | |
if (e.value != null && e.oldValue != null && e.value !== "") { | |
var dataValidation = e.range.getDataValidation(); | |
if(dataValidation != null && dataValidation.getCriteriaType() == dvType && | |
e.value.indexOf(separator) < 0 && e.oldValue.indexOf(e.value) < 0) { | |
e.range.setValue(e.oldValue + separator + e.value); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have the same error! :c
edit: i realized that it throws the error in the AppScript editor, but it's executing the script when I make edits in the spreadsheet (based on the execution history). However, it still doesn't seem to be doing anything on the sheet (the original script from spreadsheetpoint is working though).