您说的对,我是用函数做的,但是数据很多,超慢,而且中间如果有卡顿的话,数据还会产生错误。所以想着用vba解决。
第二个问题,我用vba这样做,速度很慢,因为多是数据比较大,所以希望有个更好的方法:
Sub jisuan1()
Dim rz As Long, rf As Long
Dim arz As Range, arz1 As Range, arf As Range, arf1 As Range
Dim wz As Worksheet, wf As Worksheet
Set wz = Worksheets("现任"): Set wf = Worksheets(5)
Set arz = wz.Range("k2:w59742")
Set arf = wf.Range("b2:n23948")
Set arz1 = wz.Range("j2:j59742")
Set arf1 = wf.Range("o2:o23948")
For rz = 1 To 59742
For rf = 1 To 23948
If arf1(rf) = arz1(rz) Then
arz(rz, 1) = arf(rf, 1)
arz(rz, 2) = arf(rf, 2)
arz(rz, 3) = arf(rf, 3)
arz(rz, 4) = arf(rf, 4)
arz(rz, 5) = arf(rf, 5)
arz(rz, 6) = arf(rf, 6)
arz(rz, 7) = arf(rf, 7)
arz(rz, 8) = arf(rf, 8)
arz(rz, 9) = arf(rf, 9)
arz(rz, 10) = arf(rf, 10)
arz(rz, 11) = arf(rf, 11)
arz(rz, 12) = arf(rf, 12)
arz(rz, 13) = arf(rf, 13)
Exit For
End If
Next rf
Next rz
End Sub |