Private Sub CommandButton1_Click()
If TextBox1.Text = "" Then
MsgBox "请输入要查找的简称!": Exit Sub
End If
Dim arr, rgs As Range
t = Timer
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Rows("31:10000").Hidden = False
arr = Range("b1:b10000")
For i = 31 To 10000
If (arr(i, 1) Like "*" & TextBox1.Text & "*") = False Then
If rgs Is Nothing Then
Set rgs = Range("a" & i)
Else
Set rgs = Union(rgs, Range("a" & i))
End If
End If
' If (Cells(i, 2) Like "*" & TextBox1.Text & "*") = False Then
' Range("a" & i).EntireRow.Hidden = True
' End If
Next
rgs.EntireRow.Hidden = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
MsgBox Timer - t
End Sub
用数组会快点
Private Sub CommandButton1_Click()
If TextBox1.Text = "" Then
MsgBox "请输入要查找的简称!": Exit Sub
End If
Dim arr, rgs As Range
t = Timer
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Rows("31:10000").Hidden = False
arr = Range("b1:b10000")
For i = 31 To 10000
If (arr(i, 1) Like "*" & TextBox1.Text & "*") = False Then
If rgs Is Nothing Then
Set rgs = Range("a" & i)
Else
Set rgs = Union(rgs, Range("a" & i))
End If
End If
' If (Cells(i, 2) Like "*" & TextBox1.Text & "*") = False Then
' Range("a" & i).EntireRow.Hidden = True
' End If
Next
rgs.EntireRow.Hidden = True
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
MsgBox Timer - t
End Sub
用数组会快点