Skip to content

Instantly share code, notes, and snippets.

@jeffaspenburg
Created December 31, 2020 15:43
Show Gist options
  • Save jeffaspenburg/8120bcb8e0b38dc602c4abb3ee752868 to your computer and use it in GitHub Desktop.
Save jeffaspenburg/8120bcb8e0b38dc602c4abb3ee752868 to your computer and use it in GitHub Desktop.
Google Sheets multiple sections separate by pipe
function onEdit(e) {
var oldValue;
var newValue;
var ss=SpreadsheetApp.getActiveSpreadsheet();
var activeCell = ss.getActiveCell();
if(activeCell.getColumn() == 15||16||17 && ss.getActiveSheet().getName()=='Insights') {
newValue=e.value;
oldValue=e.oldValue;
if(!e.value) {
activeCell.setValue("");
}
else {
if (!e.oldValue) {
activeCell.setValue(newValue);
}
else {
if(oldValue.indexOf(newValue) <0) {
activeCell.setValue(oldValue+'|'+newValue);
}
else {
activeCell.setValue(oldValue);
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment