|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
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
br = Sheets("变动").[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
|
评分
-
1
查看全部评分
-
|