|
- Sub lqxs()
- Dim Arr, i&, Brr, Crr, m&, n&, j&, r%, Arr1()
- Dim d, Drr, jj&, k, t, l&
- Set d = CreateObject("Scripting.Dictionary")
- Sheet1.Activate
- Arr = Sheet1.[a1].CurrentRegion
- ReDim Brr(1 To UBound(Arr), 1 To UBound(Arr, 2) - 1)
- ReDim Crr(1 To UBound(Arr), 1 To 8)
- ReDim Drr(1 To UBound(Arr), 1 To 5)
- For i = 4 To UBound(Arr)
- If Arr(i, 1) <> "" And Arr(i, 2) <> "" Then
- n = n + 1
- Brr(n, 2) = Replace(Arr(i, 2), "-", "00")
- For j = 1 To 3 Step 2
- Brr(n, j) = Arr(i, j)
- Next
- For j = 5 To UBound(Arr, 2)
- Brr(n, j - 1) = Arr(i, j)
- Next
- r = r + 1
- ReDim Preserve Arr1(1 To r)
- Arr1(r) = i
- End If
- Next
- With Sheet2
- .[a4:i5000].ClearContents
- .[a4:i5000].Borders.LineStyle = xlNone
- .[a4].Resize(n, UBound(Brr, 2)) = Brr
- .[a4].Resize(n, UBound(Brr, 2)).Borders.LineStyle = 1
- End With
- For i = 1 To r
- If i <> r Then
- js = Arr1(i + 1) - 1
- Else
- js = UBound(Arr) - 2
- End If
- ks = Arr1(i)
- For j = ks + 1 To js
- m = m + 1
- Crr(m, 1) = Arr(ks, 1)
- Crr(m, 2) = Replace(Arr(ks, 2), "-", "00")
- Crr(m, 3) = Arr(ks, 3)
- For jj = 4 To 8
- Crr(m, jj) = Arr(j, jj - 1)
- Next
- Next
- Next
- With Sheet3
- .[a4:h5000].ClearContents
- .[a4:h5000].Borders.LineStyle = xlNone
- .[a4].Resize(m, UBound(Crr, 2)) = Crr
- .[a4].Resize(m, UBound(Crr, 2)).Borders.LineStyle = 1
- End With
- For i = 1 To UBound(Crr)
- If Not d.exists(Crr(i, 4)) Then d(Crr(i, 4)) = i
- Next
- k = d.keys: t = d.items
- For i = 0 To UBound(k)
- Drr(i + 1, 1) = Crr(t(i), 1)
- Drr(i + 1, 2) = k(i)
- For j = 6 To 8
- Drr(i + 1, j - 3) = Crr(t(i), j)
- Next
- Next
- With Sheet4
- .[a4:e5000].ClearContents
- .[a4:e5000].Borders.LineStyle = xlNone
- .[a4].Resize(d.Count, UBound(Drr, 2)) = Drr
- .[a4].Resize(d.Count, UBound(Drr, 2)).Borders.LineStyle = 1
- End With
- End Sub
复制代码 |
|