|
- Sub 查找()
- Dim path, ws As Workbook, sht As Worksheet, d As Object
- Dim arr, brr, i&, j&, k
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- path = ThisWorkbook.path & "/"
- Set ws = Workbooks.Open(path & "数据表.xls")
- For Each sht In Worksheets
- If sht.Name <> "备注" Then
- arr = sht.[b1].CurrentRegion
- For i = 1 To UBound(arr)
- If Not d.exists(arr(i, 1)) Then
- d(arr(i, 1)) = Array(arr(i, 2), arr(i, 9), arr(i, 10))
- Else
- k = d(arr(i, 1))
- d(arr(i, 1)) = Array(k(0) & "," & arr(i, 2), k(1) & "," & arr(i, 9), k(2) & "," & arr(i, 10))
- End If
- Next
- End If
- Next
- ws.Close False
- arr = Range("b1:e" & Cells(Rows.Count, 2).End(3).Row)
- For i = 2 To UBound(arr)
- If d.exists(arr(i, 1)) Then
- k = d(arr(i, 1))
- For j = 2 To 4
- arr(i, j) = k(j - 2)
- Next
- End If
- Next
- Cells.Clear
- [b1].Resize(UBound(arr), 4) = arr
- Set d = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|