Sub remplircomboaveccond()
'Déclare un tableau à 2 dimensions.
Dim £Tableau() As String
Dim £cellule As Range
Dim £i As Long, £j As Integer, £y As Integer
Dim £numColTri As Byte 'numéro de la colonne à trier
Dim £nbCol As Byte ' nombre de colonne
Dim £t As Variant
£nbCol = 4
nomfeuille1 = "Salle&Batiment"
£i = Sheets(nomfeuille1).Range("b65536").End(xlUp).Row + 2 ' taille du tableau
'Dim £Tableau(1 To 4, 1 To 4, 1 To 4, 1 To 4) As String
ReDim £Tableau(1 To £i, 1 To £nbCol)
'Remplir le tableau
£i = 1
For Each £cellule In Sheets(nomfeuille1).Range("a2:b" & Sheets(nomfeuille1).Range("b65536").End(xlUp).Row)
If IsDate(£cellule.Offset(0, 2).Value) Then
If £cellule.Offset(0, 2).Value >= "31/12/2008" Then
£Tableau(£i, 1) = £cellule.Value
£Tableau(£i, 2) = £cellule.Offset(0, 1).Value
£Tableau(£i, 3) = CStr(£cellule.Offset(0, 2).Value) ' on transforme la date en string
£Tableau(£i, 4) = £cellule.Row
£i = £i + 1
End If
End If
Next £cellule
' trier le tableau
£numColTri = 1 'colonne à trier
For £i = 1 To UBound(£Tableau, £numColTri)
For £j = 1 To UBound(£Tableau, £numColTri)
If £Tableau(£j, £numColTri) > £Tableau(£i, £numColTri) Then
For £y = 1 To £nbCol
£t = £Tableau(£i, £y)
£Tableau(£i, £y) = £Tableau(£j, £y)
£Tableau(£j, £y) = £t
Next £y
End If
Next £j
Next £i
With ComboBox1
.Clear
.ColumnCount = 4
.ColumnWidths = "50;50;50;0"
.Style = fmStyleDropDownList '
.BoundColumn = 1 ' combobox1.text contient le nom
For £i = 1 To UBound(£Tableau, £numColTri)
If £Tableau(£i, 1) <> "" Then
.AddItem £Tableau(£i, 1)
.List(.ListCount - 1, 1) = £Tableau(£i, 2)
.List(.ListCount - 1, 2) = £Tableau(£i, 3)
.List(.ListCount - 1, 3) = £Tableau(£i, 4)
End If
Next £i
End With
End Sub