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
|
Dim f, Tbl()
Sub UserForm_Initialize()
Set f = Sheets("bd")
Me.ListBox1.List = Range(f.[A2], f.[b65000].End(xlUp)).Value
Me.ListBox1.MultiSelect = fmMultiSelectMulti
End Sub
Private Sub ListBox1_Change()
n = 0
For k = 0 To Me.ListBox1.ListCount - 1
If Me.ListBox1.Selected(k) = True Then
n = n + 1
ReDim Preserve Tbl(1 To 2, 1 To n)
Tbl(1, n) = Me.ListBox1.List(k, 0)
Tbl(2, n) = Me.ListBox1.List(k, 1)
End If
Next k
End Sub
Private Sub cmdValider_Click()
f.Cells(2, "e").Resize(20, 2).ClearContents
n = UBound(Tbl, 2) + 1
ReDim Preserve Tbl(1 To 2, 1 To n)
Tbl(1, n) = "xxxx"
Tbl(2, n) = "yyyy"
f.Cells(2, "e").Resize(UBound(Tbl, 2), 2) = Application.Transpose(Tbl)
Unload Me
End Sub |
Partager