Salut,
Avec un script :
function onEdit(e) {
const cell = e.range.getA1Notation();
const value = e.range.getValue();
const sheet = e.source.getActiveSheet();
if (cell === 'A1' && value === 'GL') {
console.log('pass');
const listData = sheet.getRange('C1:C20').getValues().flat();
const list = SpreadsheetApp.newDataValidation()
.requireValueInList(listData, true)
.setAllowInvalid(false)
.build();
sheet.getRange('B1').setDataValidation(list);
}
}
+ amélioration possible, si tu veux qu'en A1 lorsqu'il n'y a plus "GL" la liste en B1 soit del :
function onEdit(e) {
const cell = e.range.getA1Notation();
const value = e.range.getValue();
const sheet = e.source.getActiveSheet();
if (cell === 'A1' && value === 'GL') {
const listData = sheet.getRange('C1:C20').getValues().flat();
const list = SpreadsheetApp.newDataValidation()
.requireValueInList(listData, true)
.setAllowInvalid(false)
.build();
sheet.getRange('B1').setDataValidation(list);
} else if (cell === 'A1') {
sheet.getRange('B1').clearContent().clearDataValidations();
}
}
Voici au besoin un fichier test : https://docs.google.com/spreadsheets/d/1DJOehxNatRjgS80EaOSH1rNodCZSKRXAtPfmgwtxyTU/edit?usp=sharing