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
| Private Sub CommandButton1_Click()
With ListBox1
For i = 1 To .ListCount - 1
If .Selected(i) = True Then mess = mess & i & vbCrLf
Next
End With
MsgBox mess
End Sub
Private Sub ListBox1_Click()
MsgBox ListBox1.ListIndex
End Sub
Private Sub UserForm_Activate()
Dim plage As Range, i As Long, large
With Sheets("Ventes")
Set plage = .Range("A1").CurrentRegion
For i = 1 To plage.Columns.Count: large = large & ";" & Round(plage.Columns(i).Width): Next ' on capture la largeur des colonnes
large = Mid(large, 2, 200)
With Me.ListBox1
.RowSource = plage.Address
.ColumnHeads = True
.ColumnWidths = large
.ColumnCount = plage.Columns.Count
.ListStyle = 1
.MultiSelect = 1
End With
End With
End Sub |