|
[广告] VBA代码宝 - VBA编程加强工具 · VBA代码随查随用 · 内置多项VBA编程加强工具 ★ 免费下载 ★ ★ 使用手册★
- Sub 测试()
- Dim i%, j%, arr
- Dim dic As Object, key
- Set dic = CreateObject("scripting.dictionary")
- arr = Sheet1.Range("A1").CurrentRegion.Value
- For j = 1 To UBound(arr, 2) Step 2
- For i = 2 To UBound(arr)
- If arr(i, j) <> "" Then
- key = arr(i, j) & arr(1, j)
- dic(key) = arr(i, j + 1)
- End If
- Next
- Next
- For i = 2 To Sheet2.Cells(Rows.Count, "B").End(xlUp).Row
- For j = 3 To Sheet2.Cells(1, Columns.Count).End(xlToLeft).Column
- If Sheet2.Cells(i, 2) <> "" Then
- key = Sheet2.Cells(i, 2) & Sheet2.Cells(1, j)
- Sheet2.Cells(i, j) = dic(key)
- End If
- Next
- Next
- End Sub
复制代码 |
|