0

I am attempting to use this script to choose multiple selections in 1 cell for data validation in google sheets. I cannot get the script to work on the 200+ sheets within the workbook. Is there a way to edit the script to cover all of the sheets without adding the names of all 200+ tabs? Any help you can provide is appreciated!!!

function onEdit(e) {
var oldValue;
var newValue;
var ss=SpreadsheetApp.getActiveSpreadsheet();
var activeCell = ss.getActiveCell();
if(activeCell.getColumn() == 3 && activeCell.getRow() == 1 && ss.getActiveSheet().getName()=='Sheet1') {
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);
}
}
}
}
}
0

1 Answer 1

0

Remove && ss.getActiveSheet().getName()=='Sheet1' in the if statement.

This line is limiting the script to recognise chnages to just "Sheet1". If you remove this part of the condition, then it will work on ANY sheet

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.