Option Explicit
Option Compare Text
Dim d As Object
Sub ValidationDico()
Dim dl As Integer, Tb(), i As Integer, j As Integer, cle, liste
Set d = CreateObject("scripting.dictionary")
With Sheets("personnel")
dl = .Range("A" & Rows.Count).End(xlUp).Row
Tb = .Range("B2:AE" & dl).Value
End With
For i = LBound(Tb) To UBound(Tb)
For j = LBound(Tb, 2) To UBound(Tb, 2)
If Tb(i, j) <> "" Then d(Tb(i, j)) = ""
Next j
Next i
DicoTri d 'tri
For Each cle In d.keys
liste = liste & "," & cle
Next
With Sheets("Comptage")
.Unprotect "manu01" ' remplace mot_de_passe par ton mot de passe
With .Range("B1").Validation
.Delete
.Add Type:=xlValidateList, _
Operator:=xlBetween, _
AlertStyle:=xlValidAlertStop, _
Formula1:=liste
End With
.Protect "manu01" ' remplace mot_de_passe par ton mot de passe
End With
End Sub
Sub DicoTri(dico)
Dim i As Integer, Tbl
Tbl = d.keys ' Transfert Dictionnaire dans Array
Tri Tbl, LBound(Tbl), UBound(Tbl) ' Tri Array
d.RemoveAll ' Création du dictionnaire
For i = LBound(Tbl) To UBound(Tbl)
d(Tbl(i)) = ""
Next i
End Sub
Sub Tri(a, gauc, droi) ' Quick sort
Dim ref As String, g As Integer, d As Integer, temp
ref = a((gauc + droi) \ 2)
g = gauc: d = droi
Do
Do While a(g) < ref: g = g + 1: Loop
Do While ref < a(d): d = d - 1: Loop
If g <= d Then
temp = a(g): a(g) = a(d): a(d) = temp
g = g + 1: d = d - 1
End If
Loop While g <= d
If g < droi Then Call Tri(a, g, droi)
If gauc < d Then Call Tri(a, gauc, d)
End Sub