|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Dim ws As Worksheet
- Set d1 = CreateObject("scripting.dictionary")
- Set d2 = CreateObject("scripting.dictionary")
- With Worksheets("工作表")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(1, .Columns.Count).End(xlToLeft).Column
- brr = .Range("a1").Resize(r, c)
- For i = 2 To UBound(brr)
- d1(brr(i, 1)) = i
- Next
- For j = 2 To UBound(brr, 2)
- d2(brr(1, j)) = j
- Next
- End With
- For Each ws In Worksheets
- If ws.Name <> "工作表" Then
- With ws
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(1, .Columns.Count).End(xlToLeft).Column
- If r > 1 Then
- arr = .Range("a1").Resize(r, c)
- For i = 2 To UBound(arr)
- If d1.exists(arr(i, 1)) Then
- m = d1(arr(i, 1))
- For j = 2 To UBound(arr, 2)
- If d2.exists(arr(1, j)) Then
- n = d2(arr(1, j))
- brr(m, n) = arr(i, j)
- End If
- Next
- End If
- Next
- End If
- End With
- End If
- Next
- With Worksheets("工作表")
- .Range("a1").Resize(UBound(brr), UBound(brr, 2)) = brr
- End With
- End Sub
复制代码 |
|