1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| Private Sub UserForm_Initialize()
Dim MondicoStat As Object, MondicoMand As Object, MondicoResp As Object
Dim J As Long, T2
Set Ws = Sheets("consignes")
Set MondicoStat = CreateObject("Scripting.dictionary")
Set MondicoMand = CreateObject("Scripting.dictionary")
'Set MondicoResp = CreateObject("Scripting.dictionary")
With Ws
For J = 2 To .Range("A" & Rows.Count).End(xlUp).Row
If .Range("H" & J) <> "" Then MondicoStat(.Range("H" & J).Value) = ""
If .Range("G" & J) <> "" Then MondicoMand(.Range("G" & J).Value) = ""
'If .Range("C" & J) <> "" Then MondicoResp(.Range("C" & J).Value) = ""
Next J
End With
If MondicoStat.Count > 0 Then T2 = MondicoStat.keys: Tri T2, LBound(T2), UBound(T2): Me.mois.List = T2
If MondicoMand.Count > 0 Then T2 = MondicoMand.keys: Tri T2, LBound(T2), UBound(T2): Me.annee.List = T2
'If MondicoResp.Count > 0 Then T2 = MondicoResp.keys: Tri T2, LBound(T2), UBound(T2): Me.CbbResponsable.List = T2
End Sub
Private Sub LVW_Fill(ByVal sFilter As String, ByVal iCol As Integer)
'Variables locales
Dim iCnt As Integer
Dim iRnd As Integer
Dim oRng As Excel.Range
Dim oItem As ListItem
ListView1.ColumnHeaders.Clear
ListView1.ListItems.Clear
'Remplissage de la ListView
Set oRng = Base.Cells(1, 1)
Do Until oRng.Offset(0, 0).Value = ""
'-- En-têtes
If oRng.Row = 1 Then
For iCnt = 0 To 7
If iCnt = 0 Then
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt), 60
ElseIf iCnt = 1 Then
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt), 60
ElseIf iCnt = 2 Then
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt), 70
ElseIf iCnt = 3 Then
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt), 70
ElseIf iCnt = 4 Then
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt), 300
ElseIf iCnt = 5 Then
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt), 70
ElseIf iCnt = 6 Then
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt), 30
ElseIf iCnt = 7 Then
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt), 30
Else
ListView1.ColumnHeaders.Add , , oRng.Offset(0, iCnt), 150
End If
Next iCnt
'-- Données
Else
' iRnd = Int((4 * Rnd) + 1)
If LCase$(Left$(oRng.Offset(0, iCol), Len(sFilter))) = LCase$(sFilter) Then
Set oItem = ListView1.ListItems.Add(, , DateSerial(Left(oRng.Offset(0, 0), 4), Mid(oRng.Offset(0, 0), 5, 2), Right(oRng.Offset(0, 0), 2))) ', "Key" & iRnd, "Key" & iRnd)
For iCnt = 1 To 1 '-- 5 colonnes
oItem.ListSubItems.Add , , DateSerial(Left(oRng.Offset(0, iCnt), 4), Mid(oRng.Offset(0, iCnt), 5, 2), Right(oRng.Offset(0, iCnt), 2))
Next iCnt
For iCnt = 2 To 7
oItem.ListSubItems.Add , , oRng.Offset(0, iCnt)
Next iCnt
End If
End If
Call Filtre
With ListView1
If ListView1.Sorted = False Then
ListView1.SortKey = 7
ListView1.SortOrder = lvwAscending
ListView1.Sorted = True
End If
End With
Set oRng = oRng.Offset(1, 0)
Loop
End Sub |
Partager