|
Sub 匹配数据()
Dim d As Object
Set d = CreateObject("scripting.dictionary")
Dim ar As Variant, bi As Variant
ar = Sheets("费用明细").[a1].CurrentRegion
For i = 2 To UBound(ar)
If Trim(ar(i, 2)) <> "" Then
d(Trim(ar(i, 2))) = i
End If
Next i
For j = 3 To UBound(ar, 2)
If Trim(ar(1, j)) <> "" Then
d(Trim(ar(1, j))) = j
End If
Next j
mc = Sheets("费用明细").[a1]
br = Sheets(mc).[a1].CurrentRegion
For i = 2 To UBound(br)
If Trim(br(i, 2)) <> "" Then
n = d(Trim(br(i, 2)))
If n <> "" Then
For j = 3 To UBound(br, 2)
If Trim(br(i, j)) <> "" Then
m = d(Trim(br(1, j)))
If m <> "" Then
ar(n, m) = br(i, j)
End If
End If
Next j
End If
End If
Next i
Sheets("费用明细").[a1].CurrentRegion = ar
MsgBox "ok!"
End Sub
|
|