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
| Private Sub UserForm_Initialize()
Set f = Sheets("INSCRIPTIONS")
ColVisu = Array(1, 2, 5, 6, 7, 8, 9, 13, 11, 10, 14, 15, 20) ' Colonnes à visualiser
Ncol = UBound(ColVisu) + 1
Set d = CreateObject("Scripting.Dictionary")
BD = f.Range("A2:U" & f.[A65000].End(xlUp).Row)
'---- ComboBox trié
For i = LBound(BD) To UBound(BD)
If BD(i, 1) <> "" Then d(BD(i, 1)) = ""
Next i
'ComboBox1.List = d.keys ' sans tri
Tmp = d.keys
Tri Tmp, LBound(Tmp), UBound(Tmp)
Me.ComboBox1.List = Tmp
'-- en têtes de colonne ListBox
x = 16
y = Me.ListBox1.Top - 10
For Each k In ColVisu
Set Lab = Me.Frame1.Controls.Add("Forms.Label.1")
Lab.Caption = f.Cells(1, k)
Lab.Top = y
Lab.Left = x
x = x + f.Columns(k).Width * 1#
temp = temp & f.Columns(k).Width * 1# & ";"
Next
temp = Left(temp, Len(temp) - 1)
Me.ListBox1.ColumnCount = UBound(ColVisu) + 1
Me.ListBox1.ColumnWidths = temp
Me.Frame1.Width = 860
Me.Frame1.ScrollWidth = Me.ListBox1.Width + 1
Me.Frame1.ScrollBars = 1
'---- Contenu ListBox initial
Dim Tbl(): ReDim Tbl(1 To UBound(BD), 1 To Ncol)
For i = 1 To UBound(BD)
c = 0
For Each k In ColVisu
c = c + 1: Tbl(i, c) = BD(i, k)
Next k
Next i
TriMultiCol Tbl, LBound(Tbl), UBound(Tbl), 1
Me.ListBox1.List = Tbl
Me.Label4.Caption = Me.ListBox1.ListCount & " Ligne(s)"
End Sub
Private Sub ComboBox1_click()
Dim Tbl(): j = 0
For i = 1 To UBound(BD) ' PLANTAGE A CE NIVEAU
If BD(i, 1) = Me.ComboBox1 Then
j = j + 1: ReDim Preserve Tbl(1 To Ncol, 1 To j)
c = 0
For Each k In ColVisu
c = c + 1: Tbl(c, j) = BD(i, k)
Next k
End If
Next i
Me.ListBox1.Column = Tbl
Me.Label4.Caption = Me.ListBox1.ListCount & " Ligne(s)"
End Sub |
Partager