|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
数据量大时,宜用EXCEL自带有排序(赋值后再排序)
参考:
Sub yyzz() ''工作表自带排序(辅助列)
Application.ScreenUpdating = False
Dim d, arr, brr, ar, t
Dim ss$, i&, j&, k&, m&, n&, x&, y&
t = Timer
Set d = CreateObject("Scripting.Dictionary")
arr = Sheet1.Range("A1").CurrentRegion.Value ''数据源一
brr = Sheet3.Range("A1").CurrentRegion.Value ''数据源二
ReDim crr(1 To UBound(arr) + UBound(brr), 1 To 18)
For i = 2 To UBound(arr)
ss = arr(i, 1) & "@" & arr(i, 2) & arr(i, 3) & arr(i, 4) & arr(i, 7) & arr(i, 8)
If Not d.Exists(ss) Then
m = m + 1: d(ss) = m
For j = 1 To 8
crr(m, j) = arr(i, j)
Next
crr(m, 18) = zs(arr(i, 1)) ''中文小写转数值(自定义函数)
End If
Next
For i = 2 To UBound(brr)
ss = brr(i, 1) & "@" & brr(i, 2) & brr(i, 3) & brr(i, 4) & brr(i, 5) & brr(i, 9)
If d.Exists(ss) Then
For j = 1 To 9
crr(d(ss), j + 8) = brr(i, j)
Next
Else
m = m + 1
For j = 1 To 9
crr(m, j + 8) = brr(i, j)
Next
crr(m, 18) = zs(brr(i, 1)) ''中文小写转数值(自定义函数)
End If
Next
With Sheet4 ''运行结果落地点
[a2].CurrentRegion.Offset(1).ClearContents
[a2].Resize(m, 18) = crr
[a2].Resize(m, 18).Sort [r2], 1
[r2].Resize(m).ClearContents
End With
Application.ScreenUpdating = True
MsgBox Format(Timer - t, "0.0000s")
End Sub |
评分
-
3
查看全部评分
-
|