Learn how to assign data validation using Apps Scripts and create dynamic dependent dropdown lists for the whole column for Google Sheets.
function onEdit(){ var tabLists = "lists"; var tabValidation = "Main"; var ss = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); var datass = SpreadsheetApp.getActiveSpreadsheet().getSheetByName(tabLists); var activeCell = ss.getActiveCell(); if(activeCell.getColumn() == 1 && activeCell.getRow() > 1 && ss.getSheetName() == tabValidation){ activeCell.offset(0, 1).clearContent().clearDataValidations(); var makes = datass.getRange(1, 1, 1, datass.getLastColumn()).getValues(); var makeIndex = makes[0].indexOf(activeCell.getValue()) + 1; if(makeIndex != 0){ var validationRange = datass.getRange(3, makeIndex, datass.getLastRow()); var validationRule = SpreadsheetApp.newDataValidation().requireValueInRange(validationRange).build(); activeCell.offset(0, 1).setDataValidation(validationRule); } } }
Understand How This Script Works