|
'数据量大,速度有点慢,15s左右
'匹配成功为1,否则为空,自己修改(vbnullstring改成"0")
Option Explicit
Sub test()
Dim arr, t As String, dic, i As Long, j As Long, dt
dt = Timer
Set dic = CreateObject("scripting.dictionary")
arr = Sheets("sheet1").[a1].CurrentRegion.Value
For i = 1 To UBound(arr, 1)
t = arr(i, 1) & arr(i, 2): dic(t) = vbNullString
Next
Debug.Print Timer - dt
arr = Sheets("sheet2").[a1].CurrentRegion.Value
Debug.Print Timer - dt
For i = 2 To UBound(arr, 1)
For j = 2 To UBound(arr, 2)
t = arr(1, j) & arr(i, 1)
If dic.exists(t) Then arr(i, j) = "1" Else arr(i, j) = vbNullString
Next j, i
Debug.Print Timer - dt
With Sheets("sheet2").[a1]
.Resize(, UBound(arr, 2)).NumberFormatLocal = "@"
.CurrentRegion.Value = arr
End With
Debug.Print Timer - dt
End Sub |
评分
-
2
查看全部评分
-
|