Skip to content

Instantly share code, notes, and snippets.

@ricardomaia
Created May 24, 2022 15:37
Show Gist options
  • Save ricardomaia/456fda906f4c4f3ab22703d0560932b5 to your computer and use it in GitHub Desktop.
Save ricardomaia/456fda906f4c4f3ab22703d0560932b5 to your computer and use it in GitHub Desktop.
Multiple Selections on Google Spreadsheets
/**
@OnlyCurrentDoc
Ref: https://spreadsheetpoint.com/multiple-selection-drop-down-google-sheets/
*/
function onEdit(e) {
var oldValue;
var newValue;
var ss=SpreadsheetApp.getActiveSpreadsheet();
var activeCell = ss.getActiveCell();
if(activeCell.getColumn() == 3 && activeCell.getRow() >= 4 && ss.getSheetName != "Categorias" ) {
newValue=e.value;
oldValue=e.oldValue;
if(!e.value) {
activeCell.setValue("");
} else {
if (!e.oldValue) {
activeCell.setValue(newValue);
} else {
activeCell.setValue(oldValue+'; '+newValue);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment