In order to adapt your script and create additional dropdown menus, you need to
- create additional validation rules
- with adjusted validation ranges
- adjust the offset according to the position where the dropdown menu shall be inserted.
Sample:
var validationRange2=datass.getRange(15,baseIndex,datass.getLastRow());
var validationRule2=SpreadsheetApp.newDataValidation().requireValueInRange(validationRange2).build()
activeCell.offset(0,2).setDataValidation(validationRule2);
The full code would be:
function onEdit() {
var tablists="Dropdown Lists";
var tabValidation="Events/Incidents";
var ss=SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var datass=SpreadsheetApp.getActiveSpreadsheet().getSheetByName(tablists);
var activeCell=ss.getActiveCell();
if(activeCell.getColumn()==3&&activeCell.getRow()>1&&ss.getSheetName()==tabValidation){
activeCell.offset(0,1).clearContent().clearDataValidations();
var base=datass.getRange(2,1,1,5).getValues();
var baseIndex=base[0].indexOf(activeCell.getValue())+1;
Logger.log(baseIndex);
if(baseIndex!=0){
var validationRange=datass.getRange(3,baseIndex,10);
var validationRule=SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build()
activeCell.offset(0,1).setDataValidation(validationRule);
var validationRange2=datass.getRange(15,baseIndex,datass.getLastRow());
var validationRule2=SpreadsheetApp.newDataValidation().requireValueInRange(validationRange2).build()
activeCell.offset(0,2).setDataValidation(validationRule2);
activeCell.offset(0,3).setDataValidation(validationRule2);
}
}
}
To obtain a better understanding of the code, please refer to the Apps Script documentation and tutorials