不行,我也只能提速到20秒。关键是兄台的数据有找不到的情况,如果都能找到的话可以用lookup,速度可以提高10倍。
或者兄台可以自编一个2叉树查找的代码(相当于lookup),不过不太好编就是了。
文件太大只贴代码:
Application.ScreenUpdating = False
Dim i&, j&, p&, q&
Dim rng As Range
With Sheets("查找范围")
p = Cells(65536, 2).End(xlUp).Row
q = .Cells(65536, 2).End(xlUp).Row
Range(Cells(2, 4), Cells(p, 4)) = Application.VLookup(Range(Cells(2, 1), Cells(p, 1)), .Range(.Cells(2, 1), .Cells(q, 2)), 2, 0)
End With
arr = Range(Cells(2, 1), Cells(p, 4))
For i = 1 To p - 1
If IsError(arr(i, 4)) Then
If arr(i, 1) = "" Then
arr(i, 3) = "K"
Else
arr(i, 3) = "N"
End If
arr(i, 4) = ""
Else
arr(i, 3) = "Y"
End If
Next i
Range(Cells(2, 1), Cells(p, 4)) = arr |