Skip to content

Commit

Permalink
Allow multiple columns to have multiple values
Browse files Browse the repository at this point in the history
  • Loading branch information
joecorall committed Jul 23, 2024
1 parent e8a2e74 commit 99c58d7
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions google/appsscript/Multi-Dropdown.gs
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
function onEdit(e) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getActiveSheet();
if (sheet.getName() != "Sheet1") {
return;
}

var activeCell = ss.getActiveCell();
if (activeCell.getColumn() != 14 || ss.getActiveSheet().getName() != "Sheet1") {
var columnNames = ["Related Department", "Language"];
var columnName = sheet.getRange(1, activeCell.getColumn()).getValue();
var pattern = /^Contributor Relator \d+$/;
if (!columnNames.includes(columnName) && !pattern.test(columnName)) {
return;
}

var delimiter = ' ; ';
var newValue = e.value;
var oldValue = e.oldValue;
if (!newValue) {
Expand All @@ -14,7 +23,7 @@ function onEdit(e) {
if (!oldValue) {
activeCell.setValue(newValue);
} else {
activeCell.setValue(oldValue + ' ; ' + newValue);
activeCell.setValue(oldValue + delimiter + newValue);
}
}
}

0 comments on commit 99c58d7

Please sign in to comment.