Private sArray()
'=========================='
Private Sub CommandButton6_Click()
Dim ws As Worksheet, i As Long, NameWs As String, chk As Boolean
chk = False
i = ListBox1.ListIndex
If i >= 0 Then
NameWs = ListBox1.List(i, 0)
For Each ws In ThisWorkbook.Worksheets 'Sao lại thêm đoạn kiểm tra này, sao không dùng code để liệt kê tên sheet cho chính xác.'
If ws.Name = NameWs Then
chk = True: Exit For
Else
chk = False
End If
Next ws
If chk = False Then
MsgBox "Khong co sheet " & NameWs: TextBox1.SetFocus: Exit Sub
Else
ThisWorkbook.Worksheets(NameWs).Visible = xlSheetVisible
ThisWorkbook.Worksheets(NameWs).Select
End If
End If
Unload Me
End Sub
'=========================='
Private Sub TextBox1_Change()
Dim Clls As Range, Temp As Variant, i As Long, FCol As Long
Dim Arr, Arr1
If TextBox1.Value = "" Then
Me.ListBox1.List() = sArray
Me.ListBox1.ListIndex = 0
Exit Sub
End If
Arr = Filter2DArray(sArray, 1, "*" & TextBox1.Value & "*", False)
If Not IsArray(Arr) Then
Arr = Filter2DArray(sArray, 2, "*" & TextBox1.Value & "*", False)
If Not IsArray(Arr) Then ListBox1.Clear: Exit Sub
End If
Me.ListBox1.List() = Arr
Me.ListBox1.ListIndex = 0
End Sub
'=========================='
Private Sub UserForm_Initialize()
With Sheets("TRANGCHU")
sArray = .Range("N3", .Range("P65535").End(3)).Value
End With
Me.ListBox1.List() = sArray
Me.ListBox1.ListIndex = 0
End Sub