|
想要左边的关键字匹配到对应右边的单元格中,求助字典该怎么优化(原数据有几千行),谢谢!
Sub Rev()
Dim d, ar
Set d = CreateObject("Scripting.Dictionary")
ar = [A1].CurrentRegion
For i = 2 To UBound(ar)
d(ar(i, 1) & ar(1, 3) & ar(i, 2)) = ar(i, 3)
Next i
For i = 2 To Cells(Rows.Count, 8).End(xlUp).Row
For j = 9 To Cells(1, Columns.Count).End(xlToLeft).Column
s = Cells(i, 8) & Cells(1, j)
If d.exists(s) Then Cells(i, j) = d(s)
Next j, i
End Sub
关键字1 | 关键字2 | 1 | 2 | 3 | | | 关键字 | B1 | B2 | B3 | B4 | B5 | B6 | A | B1 | 200 | 201 | 202 | | | A1 | 200 | 290 | 380 | 470 | 560 | 650 | A | B2 | 290 | 203 | 370 | | | A2 | | | | | | | A | B3 | 380 | 205 | 538 | | | A3 | | | | | | | A | B4 | 470 | 207 | 706 | | | | | | | | | | A | B5 | 560 | 209 | 874 | | | | | | | | | | A | B6 | 650 | 211 | 1042 | | | | | | | | | |
|
|