|
Option Explicit
Sub 查号匹对1()
Dim strs As String, ar
Dim Arr, Brr, x&, i&, R&, irow, j&
Dim ilastrow&, sht As Worksheet
Dim dic As Object
Dim Tim As Single
Dim rng As Range
Tim = Timer
Set dic = CreateObject("scripting.dictionary")
Application.ScreenUpdating = False
Application.Calculation = xlCalculationManual
Set sht = Sheets("计费")
With sht
ilastrow = .Cells.Find("*", Cells(1, 1), xlValues, xlWhole, xlByRows, xlPrevious).Row
.[J5:M9999] = Empty
Arr = .Range("A5:M" & ilastrow)
End With
For i = 1 To UBound(Arr)
dic(Arr(i, 3)) = i
Next
Brr = Sheets("系统数据").UsedRange
For i = 2 To UBound(Brr)
If dic.exists(Brr(i, 2)) Then
x = dic(Brr(i, 2))
Arr(x, 2) = Brr(i, 1)
Arr(x, 5) = Brr(i, 5)
Arr(x, 12) = Brr(i, 13)
End If
If Len(Brr(i, 13)) Then
ar = Split(Brr(i, 13), ",")
For j = 0 To UBound(ar)
If Len(ar(j)) And dic.exists(ar(j)) Then
x = dic(ar(j))
Arr(x, 12) = Brr(i, 13)
Arr(x, 13) = Brr(i, 2)
strs = strs & x + 4 & ","
'Exit For
End If
Next
End If
Next
With sht
.Range("A5").Resize(UBound(Arr), 13) = Arr
strs = Left(strs, Len(strs) - 1)
ar = Split(strs, ",")
For i = 0 To UBound(ar)
If rng Is Nothing Then
Set rng = .Cells(ar(i), 3)
Else
Set rng = Union(rng, .Cells(ar(i), 3))
End If
Next
If Not rng Is Nothing Then rng.Interior.Color = RGB(255, 255, 0)
End With
Application.Calculation = xlCalculationAutomatic
Application.ScreenUpdating = True
MsgBox Format(Timer - Tim, "0.00")
End Sub
|
|