chaoban888
Thành viên mới

- Tham gia
- 28/1/10
- Bài viết
- 42
- Được thích
- 8
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Application.ScreenUpdating = False
If Target.Column = 1 Then 'Thay số 1 ở dòng này thành số 2 là được.
If Target.Row > 1 And Target.Row < 1000 And Target.Count = 1 Then
If Target = "" Then
thaydoi
Else
Hide
End If
End If
Else
Hide
End If
Application.ScreenUpdating = True
End Sub
Sub loc()
Dim dl(), i As Long, c As Byte
dl = Sheet2.[B2:B1000].Value
ActiveSheet.ListBox1.Clear
c = ActiveCell.Column
For i = 1 To UBound(dl)
If dl(i, c) <> "" Then
If TV(dl(i, c)) Like TV("*" & ActiveSheet.TextBox1.Value & "*") Then
ActiveSheet.ListBox1.AddItem dl(i, c)
End If
End If
Next
End Sub
Bạn sửa lại thế này.Mình chuyển cột B thì nó lại báo lỗi ở đây là sao vậy nhỉ ?Mã:Sub loc() Dim dl(), i As Long, c As Byte dl = Sheet2.[B2:B1000].Value ActiveSheet.ListBox1.Clear c = ActiveCell.Column For i = 1 To UBound(dl) If dl(i, c) <> "" Then If TV(dl(i, c)) Like TV("*" & ActiveSheet.TextBox1.Value & "*") Then ActiveSheet.ListBox1.AddItem dl(i, c) End If End If Next End Sub
Sub loc()
Dim dl(), i As Long, c As Byte
dl = Sheet2.[B2:B1000].Value
ActiveSheet.ListBox1.Clear
'c = ActiveCell.Column
For i = 1 To UBound(dl)
If dl(i, 1) <> "" Then
If TV(dl(i, 1)) Like TV("*" & ActiveSheet.TextBox1.Value & "*") Then
ActiveSheet.ListBox1.AddItem dl(i, 1)
End If
End If
Next
End Sub