|
- Sub test()
- Dim r%, i%
- Dim arr, brr
- Dim d As Object
- Set d = CreateObject("scripting.dictionary")
- With Worksheets("sheet1")
- c = .Range("aw6").End(xlToLeft).Column
- arr = .Range("ai6").Resize(1, c - 34)
- For j = 1 To UBound(arr, 2)
- d(CStr(arr(1, j))) = Empty
- Next
- r = .Columns("l:ac").Find(what:="*", LookIn:=xlValues, lookat:=xlWhole, searchorder:=xlByRows, searchdirection:=xlPrevious).Row
- arr = .Range("l14:ac" & r)
- ReDim brr(1 To UBound(arr), 1 To UBound(arr, 2))
- For j = 1 To UBound(arr, 2)
- m = 0
- For i = 1 To UBound(arr)
- If InStr(arr(i, j), "-") <> 0 Then
- xm = Split(arr(i, j), "-")
- If Not d.exists(xm(1)) Then
- m = m + 1
- brr(m, j) = arr(i, j)
- End If
- End If
- Next
- Next
- .Range("ae14").Resize(UBound(brr), UBound(brr, 2)) = brr
- ReDim crr(1 To 4, 1 To 18 * 5)
- For j = 1 To UBound(brr, 2)
- n = j * 5 - 4
- For i = 1 To 5
- If Len(brr(i, j)) = 0 Then
- Exit For
- End If
- xm = Split(brr(i, j), "-")
- crr(1, n) = brr(i, j)
- crr(3, n) = xm(1)
- crr(4, n) = xm(0)
- n = n + 1
- Next
- Next
- .Range("ax14").Resize(1, UBound(crr, 2)).NumberFormatLocal = "@"
- .Range("ax14").Resize(UBound(crr), UBound(crr, 2)) = crr
-
- End With
- End Sub
复制代码 |
|