Created
January 9, 2023 10:59
-
-
Save aldrincab/311595c3afc6fef7f37bfa42051e220c to your computer and use it in GitHub Desktop.
Hello, I am new to this and I found an old post with this code. I am currently using it but it affects all tabs of my spreadsheet. Is there a way for it to work on a specific tab only? Thank you.
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