Re : Listes déroulantes à 3 niveaux (+10 000) lignes
Merci pour votre retour.
Vraiment très complet comme site.
J'ai trouvé le tuto : Création de listes à partir d'une BD
Pourriez-vous m'aider à décrypter ce code VBA:
A partir de la BD, crée des listes nommées utilisables avec Indirect()
Après la création des listes, la BD peut être supprimée
Sub CreeListeBD()
colBD = 1
colListe = 8
Set f = Sheets("bd")
ligne = 1
f.Cells(ligne + 1, colListe).Resize(1000, 10).Clear
Set mondico = CreateObject("Scripting.Dictionary")
For Each c In Range(f.Cells(2, colBD), f.Cells(65000, colBD).End(xlUp))
mondico(c.Value) = c.Value
Next c
f.Cells(ligne, colListe) = "Liste"
f.Cells(ligne, colListe).Font.Bold = True
f.Cells(ligne + 1, colListe).Resize(mondico.Count) = Application.Transpose(mondico.items)
ActiveWorkbook.Names.Add Name:="Liste", RefersTo:=f.Cells(ligne + 1, colListe).Resize(mondico.Count)
'---- niv 2,3,..
For niv = 2 To 3 ' adapter le nombre de niveaux
colBD = colBD + 1
colListe = colListe + 2
ligne = 1
For Each c In Range(f.Cells(2, colListe - 2), f.Cells(65000, colListe - 2).End(xlUp))
If c <> "" And c.Font.Bold <> True Then
Set mondico = CreateObject("Scripting.Dictionary")
For Each d In Range(f.Cells(2, colBD), f.Cells(65000, colBD).End(xlUp))
If d.Offset(, -1) = c Then mondico(d.Value) = d.Value
Next d
f.Cells(ligne, colListe) = c
f.Cells(ligne, colListe).Font.Bold = True
f.Cells(ligne + 1, colListe).Resize(mondico.Count) = Application.Transpose(mondico.items)
ActiveWorkbook.Names.Add Name:=Replace(c, " ", "_"), RefersTo:=f.Cells(ligne + 1, colListe).Resize(mondico.Count)
ligne = ligne + mondico.Count + 1
End If
Next c
Next niv
End Sub
Merci