Option Explicit
Dim arr()
Private Sub cmddong_Click()
Unload Me
Application.Calculation = xlCalculationAutomatic
End Sub
Private Sub cmdnhap_Click()
Dim j As Long, iCel As Long, iList As Long, Res(1 To 1, 1 To 4)
iCel = ActiveCell.Row
iList = lbdmkh.ListIndex
For j = 1 To 4
Res(1, j) = Me.lbdmkh.List(iList, 1)
Next j
Sheet3.Range("H" & iCel).Resize(, 4) = Res
ActiveCell.Offset(1).Select
End Sub
Private Sub txttimkiem_change()
Dim i As Long, j As Long
With lbdmkh
.Clear
For i = LBound(arr, 1) To UBound(arr, 1)
For j = 1 To 6
If InStr(LCase$(arr(i, j)), LCase$(Trim(txttimkiem.Text))) Then
.AddItem arr(i, 1)
.List(.ListCount - 1, 1) = arr(i, 2)
.List(.ListCount - 1, 2) = arr(i, 3)
.List(.ListCount - 1, 3) = arr(i, 4)
.List(.ListCount - 1, 4) = arr(i, 5)
.List(.ListCount - 1, 5) = arr(i, 6)
End If
Next j
Next i
End With
End Sub
Private Sub UserForm_Initialize()
Dim lr2 As Long
lr2 = Sheet1.Range("d" & Rows.Count).End(3).Row
arr = Sheet1.Range("a10:f" & lr2).Value2
With Me.lbdmkh
.ColumnCount = 6 ' chia thanh 6 cot
.ColumnWidths = "25,70,33,110,210" ' do rong cot
.List = arr ' chi do duoc mang, ko do duoc range
End With
Application.Calculation = xlCalculationManual
End Sub