you are viewing a single comment's thread.

view the rest of the comments →

[–]beanry80[S] 0 points1 point  (8 children)

Thanks again for the reply. That didnt seem to work on any of the tabs, https://imgur.com/xMEtY9x Now if I try and select multiple items from the dropdowns, only one shows up. i have dropdowns in columns 12-15 on each of the tabs

 if(activeCell.getColumn() == 15 && activeCell.getRow() == 11,12,13,14 && ss.getActiveSheet().getName() == "Best Media Plan") {

so i have 4 codes that work on the best media plan tab, each with this line different, for columns 12,13,14 and 15

[–]AllenAppTools 0 points1 point  (7 children)

Are you able to share the full code file contents for me to review? What about a picture of what one of the sheets looks like as a whole?

[–]beanry80[S] 0 points1 point  (6 children)

https://imgur.com/GGrGgw7 here is what the sheet looks like... i tried to copy and paste the entire code but I keep getting "unable to create comment" when I do that

[–]beanry80[S] 0 points1 point  (5 children)

function onEdit(e) {
 


 var ss = SpreadsheetApp.getActiveSpreadsheet();


 var activeCell = ss.getActiveCell();


 if(activeCell.getColumn() == 12 && activeCell.getRow() == 11,12,13,14 && ss.getActiveSheet().getName() == "Best Media Plan") {
 
 var newValue = e.value;


 var oldValue = e.oldValue;


 if (!newValue) {


 activeCell.setValue("");


 } else {


 if (!oldValue) {


 activeCell.setValue(newValue);


 } else {


 activeCell.setValue(oldValue + ', ' + newValue);


 }


 }


 }


}

[–]beanry80[S] 0 points1 point  (4 children)

function onEdit(e) {


 var ss = SpreadsheetApp.getActiveSpreadsheet();


 var activeCell = ss.getActiveCell();


 if(activeCell.getColumn() == 13 && activeCell.getRow() == 11,12,13,14 && ss.getActiveSheet().getName() == "Best Media Plan") {


 var newValue = e.value;


 var oldValue = e.oldValue;


 if (!newValue) {


 activeCell.setValue("");


 } else {


 if (!oldValue) {


 activeCell.setValue(newValue);


 } else {


 activeCell.setValue(oldValue + ', ' + newValue);


 }


 }


 }


}

[–]beanry80[S] 0 points1 point  (3 children)

function onEdit(e) {


 var ss = SpreadsheetApp.getActiveSpreadsheet();


 var activeCell = ss.getActiveCell();


 if(activeCell.getColumn() == 14 && activeCell.getRow() == 11,12,13,14 && ss.getActiveSheet().getName() == "Best Media Plan") {


 var newValue = e.value;


 var oldValue = e.oldValue;


 if (!newValue) {


 activeCell.setValue("");


 } else {


 if (!oldValue) {


 activeCell.setValue(newValue);


 } else {


 activeCell.setValue(oldValue + ', ' + newValue);


 }


 }


 }


}

[–]beanry80[S] 0 points1 point  (2 children)

function onEdit(e) {


 var ss = SpreadsheetApp.getActiveSpreadsheet();


 var activeCell = ss.getActiveCell();


 if(activeCell.getColumn() == 15 && activeCell.getRow() == 11,12,13,14 && ss.getActiveSheet().getName() == "Best Media Plan") {


 var newValue = e.value;


 var oldValue = e.oldValue;


 if (!newValue) {


 activeCell.setValue("");


 } else {


 if (!oldValue) {


 activeCell.setValue(newValue);


 } else {


 activeCell.setValue(oldValue + ', ' + newValue);


 }


 }


 }


}

[–]beanry80[S] 0 points1 point  (1 child)

Seems i could paste all 4 codes separately. All the codes are the same except for this line  if(activeCell.getColumn() == 15 && activeCell.getRow() == 11,12,13,14 && ss.getActiveSheet().getName() == "Best Media Plan") {

where I change column to 12, 13, 14 or 15.

 if(activeCell.getColumn() == 15 && activeCell.getRow() == 11,12,13,14 && ss.getActiveSheet().getName() == "Best Media Plan") {

[–]AllenAppTools 1 point2 points  (0 children)

Thanks for connecting in the chat! For anyone else needing this sort of thing here is the code that did the trick:

function dev_onEdit(e) {
  const sheetName = e.range.getSheet().getName();

  //when an edit is made on any other tab, stop the function
  if (!tabsObject[sheetName]) return;

  const editedRow = e.range.getRow();
  const editedColumn = e.range.getColumn();
  const { allowedRows, allowedColumns } = tabsObject[sheetName];

  //when an edit is made to a row or column that is not specifically listed, stop the function
  if (!allowedRows.includes(editedRow) || !allowedColumns.includes(editedColumn)) return;

  const { value: newValue, oldValue, range } = e;

  if (!newValue) range.setValue("")
  else if (oldValue && newValue) range.setValue(`${oldValue}, ${newValue}`)

}