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
| Private Sub UserForm_Activate()
'Set a reference to Microsoft Windows Common Controls by
'using Tools > References in the Visual Basic Editor (Alt+F11)
'Set some of the properties for the ListView
With Me.LISTE
.Gridlines = True
.HideColumnHeaders = False
.View = lvwReport
End With
'Call the sub to fill the ListView
Call LoadListView
End Sub
Private Sub LoadListView()
Dim wksSource As Worksheet
Dim LstItem As ListItem
Dim i As Long
Dim labels()
labels = Array("A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L")
Set wksSource = Worksheets("Feuil1")
Me.LISTE.ColumnHeaders.Add Text:="L", Width:=90, Alignment:=lvwColumnLeft
Me.LISTE.ColumnHeaders.Add Text:="V", Width:=90, Alignment:=lvwColumnCenter
Me.LISTE.ColumnHeaders.Add Text:="Contenu", Width:=90, Alignment:=lvwColumnCenter
'Fill the ListView
For i = 0 To 11
Set LstItem = Me.LISTE.ListItems.Add(Text:=Format(i))
LstItem.ListSubItems.Add Text:=labels(i)
LstItem.ListSubItems.Add Text:=CStr(wksSource.Range("A1").Offset(0, i))
Next i
End Sub |
Partager