![]() |
|
Forum
|
|
|
#1 (permalink) |
|
XLDnaute Nouveau
Date d'inscription: septembre 2007
Messages: 16
|
Voici une méthode pour alimenter une listbox sans doublons et par ordre alphabétique
Ce code doit se situer dans le code de l'userform concerné Code:
PrivateSub UserForm_Initialize()
Dim c As Range
Dim tablo()
Dim i As Integer, j As Integer
Dim temp As String
Dim present As Boolean
ReDim tablo(1 To 1)
tablo(1) = Cells(1, 1)
For Each c In Sheets("Feuil1").Range("A1:A" & Range("a65536").End(xlUp).Row)
present = False
For i = 1 To UBound(tablo)
If tablo(i) = c Then present = True
Next i
If Not present Then
ReDim Preserve tablo(1 To UBound(tablo) + 1)
tablo(UBound(tablo)) = c
End If
For i = 1 To UBound(tablo)
For j = 1 To UBound(tablo)
If tablo(i) < tablo(j) Then
temp = tablo(i)
tablo(i) = tablo(j)
tablo(j) = temp
End If
Next j
Next i
Next c
ListBox1.List = tablo
End Sub
Ce code fut proposé sur un fil par Hervé Dernière modification par FAQ XLD ; 23/10/2007 à 21h59. |
|
|
|
| ANNONCES | |
![]() |
| Liens sociaux |
| Outils de la discussion | |
|
|
Discussions similaires
|
||||
| Discussion | Auteur | Forum | Réponses | Dernier message |
| Trier une listbox par ordre alphabétique | abraxar_27 | Forum Excel | 6 | 22/08/2007 15h00 |
| ordre alphabétique listbox en vba | stoko | Forum Excel Downloads - Archives | 1 | 20/10/2003 15h14 |
| Classer une listbox par ordre alphabetique | bichon | Forum Excel Downloads - Archives | 4 | 05/06/2003 21h32 |
| trier par ordre alphabetique une listbox | bichon | Forum Excel Downloads - Archives | 4 | 02/06/2003 22h19 |