返回列表 上一主題 發帖

如何達成兩個listbox的水平捲軸同步?

回復 1# earl
試試看
  1. Dim AR(), Msg As Boolean
  2. Private Sub UserForm_Initialize()
  3.     AR = Array(ListBox1, ListBox2)  '所有ListBox
  4.     Set myitem = Range("A1:I4")     '這裡有修改
  5.     Set mydb = Range("A2:I4")
  6.     With AR(0) 'ListBox1
  7.         .ColumnCount = 9
  8.        .RowSource = myitem.Address
  9.     End With
  10.     With AR(1) 'ListBox2
  11.            .ColumnCount = 9
  12.            .RowSource = mydb.Address
  13.     End With
  14. End Sub
  15. Private Sub ListBox1_Click()
  16.     If Msg Then Exit Sub
  17.     Ex ListBox1.ListIndex
  18. End Sub
  19. Private Sub ListBox2_Click()
  20.     If Msg Then Exit Sub
  21.     Ex ListBox2.ListIndex
  22. End Sub
  23. Private Sub Ex(OB As Integer)
  24.     Dim E As Variant
  25.     Msg = True
  26.     For Each E In AR
  27.         E.ListIndex = OB ' 所有ListBox 水平捲軸都同步
  28.     Next
  29.     Msg = False
  30. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

回復 3# stillfish00
    哈,我眼花了亂解.VBA的功力有限ㄚ.
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 生氣,就是拿別人的過錯來懲罰自己。
返回列表 上一主題