|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim ws As Worksheet
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- For Each ws In Worksheets
- If ws.Name Like "*号场" Then
- With ws
- r = .Cells(.Rows.Count, 5).End(xlUp).Row
- arr = .Range("a3:ab" & r)
- For i = 1 To UBound(arr) Step 3
- xm = arr(i, 5) & "+" & arr(i + 1, 5)
- d(xm) = Array(arr(i, 28), arr(i + 1, 28))
- xm = arr(i + 1, 5) & "+" & arr(i, 5)
- d(xm) = Array(arr(i + 1, 28), arr(i, 28))
- Next
- End With
- End If
- Next
- With Worksheets("得")
- r = .Cells(.Rows.Count, 1).End(xlUp).Row
- c = .Cells(1, .Columns.Count).End(xlToLeft).Column
- arr = .Range("a1:ad" & r)
- For i = 1 To UBound(arr)
- For j = 3 To 23 Step 4
- If Len(arr(i, j)) <> 0 And Len(arr(i, j + 1)) <> 0 Then
- xm = arr(i, j) & "+" & arr(i, j + 1)
- If d.exists(xm) Then
- brr = d(xm)
- arr(i, j + 2) = brr(0)
- arr(i, j + 3) = brr(1)
- End If
- End If
- Next
- Next
- .Range("a1").Resize(UBound(arr), UBound(arr, 2)) = arr
- End With
- End Sub
复制代码 |
|