Mong các cao thủ chỉ giáo theo tiêu đề trên:
Các ví dụ dataselector rất hay cho việc nhập tìm kiếm mặt hàng nhanh. Nhưng tất cả các ví dụ đều sử dụng vùng tham chiếu không hiểu sao khi truy xuất kéo thanh trượt rất chậm mới hiện lên để thấy mặt hàng cần tìm. làm cho việc áp dụng dataselector rất khó khăn. Mình có tham khảo ví dụ : Synchronize ListBoxes họ viết khi mình kéo thanh trượt dữ liệu có tới cả 2000 dòng mà vẫn hiện lên rất nhanh vậy nguyên nhân là đâu. làm thế nào để kết hợp Synchronize ListBoxes phần listbox vào trong listbox dataselector? Mong các cao thử giúp đệ! Tìm hoài chưa ra! đây là đoạn code đó>
' macros written 20000117 by Ole P. Erlandsen,
ope@erlandsendata.no Option Explicit
Private Sub btnOK_Click()
Me.Hide
If Application.International(xlCountrySetting) = 47 Then ' Norwegian text
MsgBox "Fra ListBox1: " & Me.ListBox1.List(Me.ListBox1.ListIndex) & Chr(13) & Chr(13) & _
"Fra ListBox2: " & Me.ListBox2.List(Me.ListBox2.ListIndex), vbInformation, "Du valgte dette:"
Else ' English text
MsgBox "From ListBox1: " & Me.ListBox1.List(Me.ListBox1.ListIndex) & Chr(13) & Chr(13) & _
"From ListBox2: " & Me.ListBox2.List(Me.ListBox2.ListIndex), vbInformation, "You selected this:"
End If
End Sub
Private Sub ListBox1_Change()
UpdateListBox Me.ListBox2, Me.ListBox1.ListIndex ' update the items in ListBox2
End Sub
Private Sub UserForm_Initialize()
With Me
' edit the caption and labels in the dialog
If Application.International(xlCountrySetting) = 47 Then ' Norwegian text
.Caption = "Synkroniser listebokser"
.Label1.Caption = "Velg en kategori:"
.Label2.Caption = "Velg en enhet fra denne kategorien:"
Else ' English text
.Caption = "Synchronize listboxes"
.Label1.Caption = "Please select a category:"
.Label2.Caption = "Please select an item from this category:"
End If
' update the items in ListBox, this will update the items in ListBox2
UpdateListBox .ListBox1, -1
End With
End Sub
Private Sub UpdateListBox(lb As MSForms.ListBox, IndexValue As Integer)
Const FirstInputRow As Integer = 5
Dim LastInputRow As Integer, ColumnIndex As Integer, InputRange As Range
ColumnIndex = IndexValue + 2 ' determine which column to get list items from
LastInputRow = Cells(FirstInputRow, ColumnIndex).End(xlDown).Row ' determine the last input row
Set InputRange = ActiveSheet.Range(Cells(FirstInputRow, ColumnIndex), Cells(LastInputRow, ColumnIndex))
With lb
.ColumnHeads = True ' use the row above input range as header
.RowSource = InputRange.Address ' set the input range
'.RowSource = "'" & ActiveSheet.Name & "'!" & Range(Cells(FirstInputRow, ColumnIndex), Cells(LastInputRow, ColumnIndex)).Address
'.RowSource = Range(Cells(FirstInputRow, ColumnIndex), Cells(LastInputRow, ColumnIndex)).Address
.ListIndex = 0 ' select the first item
End With
Set InputRange = Nothing
End Sub