Re : lister des noms avec un Userform
Re,
Essayes ce code :
Private Sub UserForm_Initialize()
Dim Tablo, i As Integer, j As Integer, Num As Variant
' Ouverture du fichier contenant la feuille contenant le tableau
Workbooks.Open Filename:="G:\GESTION EQUIPES\BASE EQUIPES\BASE PERSONELS.xls"
' Désignation de la feuille du classeur contenant le tableau
With Workbooks("BASE PERSONELS.xls").Sheets(" INTERIM POUR ERIC")
' Définition du tableau
Tablo = .Range("C2:C" & .Range("C65536").End(xlUp).Row)
'Elimination des codes en doublons
For i = 1 To UBound(Tablo) - 1
If Tablo(i, 1) <> "" Then
For j = i + 1 To UBound(Tablo)
If Tablo(j, 1) <> "" Then
If Tablo(j, 1) = Tablo(i, 1) Then
Tablo(j, 1) = ""
Else
If Tablo(j, 1) < Tablo(i, 1) Then 'Mise en ordre Croissant
Num = Tablo(i, 1)
Tablo(i, 1) = Tablo(j, 1)
Tablo(j, 1) = Num
End If
End If
End If
Next j
End If
Next i
End With
' Attribution des valeurs à la liste
For i = 1 To UBound(Tablo)
If Tablo(i, 1) <> "" Then
ComboBox1.AddItem Tablo(i, 1)
End If
Next i
End Sub
Private Sub ComboBox1_Change()
Dim Tablo, i As Integer
' Effacement de la liste précédente
ListBox1.Clear
' Désignation de la feuille du classeur contenant le tableau
With Workbooks("BASE PERSONELS.xls").Sheets(" INTERIM POUR ERIC")
Tablo = .Range("A2:C" & .Range("C65536").End(xlUp).Row)
' Attribution des noms en fonction des compétences
For i = 1 To UBound(Tablo)
If Tablo(i, 3) = ComboBox1 Then
ListBox1.AddItem Tablo(i, 1)
End If
Next i
End With
End Sub
Cordialement
Bernard