返回列表 上一主題 發帖

[發問] 請教 ListBox1.List 之Column疑問?

回復 1# yangjie
試試看
  1. Private Sub ListBox1_Change()  '點選LISTBOX1
  2. With ListBox1
  3. For i = 1 To 3
  4. Cells(1, i) = .List(.ListIndex, i - 1)
  5. Next
  6. End With
  7. End Sub


  8. Private Sub ListBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)  '離開LISTBOX1
  9. ListBox1.Visible = False
  10. End Sub

  11. Private Sub UserForm_Initialize()  '表單初始化
  12.         Set d = CreateObject("Scripting.Dictionary")
  13.                   With Sheets("基本資料")
  14.                       For Each a In .Range(.Cells(2, 4), .Cells(65536, 4).End(xlUp))
  15.                           d(a & "") = Array(a.Value, a.Offset(, -3).Value, a.Offset(, -2).Value)
  16.                       Next
  17.                  End With
  18.        If d.Count = 0 Then Exit Sub
  19. With ListBox1
  20. .List = Application.Transpose(Application.Transpose(d.items))
  21. .ColumnCount = 3
  22. .Visible = True
  23. End With
  24. End Sub
複製代碼
學海無涯_不恥下問

TOP

        靜思自在 : 多做多得。少做多失。
返回列表 上一主題