|
- Sub lqxs()
- Dim Arr, i&, j&, aa, x$, y$
- Dim d, k, t, d1, k1, t1
- Application.DisplayAlerts = False
- Set d = CreateObject("Scripting.Dictionary")
- Set d1 = CreateObject("Scripting.Dictionary")
- Sheet1.Activate
- Arr = [a1].CurrentRegion
- For i = 3 To UBound(Arr)
- x = Arr(i, 9) & "," & Arr(i, 14)
- d(x) = d(x) & i & ","
- y = Arr(i, 10) & "," & Arr(i, 14)
- d1(y) = d1(y) & i & ","
- Next
- k = d.keys: t = d.items
- With Sheet2
- .[a3:g5000].ClearContents
- .[a3].Resize(d.Count) = Application.Transpose(k)
- .[a3].Resize(d.Count).TextToColumns DataType:=xlDelimited, Comma:=True
- For i = 0 To UBound(k)
- t(i) = Left(t(i), Len(t(i)) - 1)
- If InStr(t(i), ",") Then
- aa = Split(t(i), ",")
- For jj = 15 To UBound(Arr, 2)
- If jj <> UBound(Arr, 2) - 1 Then
- For j = 0 To UBound(aa)
- .Cells(i + 3, jj - 12) = .Cells(i + 3, jj - 12) + Arr(aa(j), jj)
- Next
- Else
- .Cells(i + 3, jj - 12) = Arr(aa(0), jj)
- End If
- Next
- Else
- For jj = 15 To UBound(Arr, 2)
- If jj <> UBound(Arr, 2) - 1 Then
- For j = 0 To UBound(aa)
- .Cells(i + 3, jj - 12) = .Cells(i + 3, jj - 12) + Arr(t(i), jj)
- Next
- Else
- .Cells(i + 3, jj - 12) = Arr(t(i), jj)
- End If
- Next
- End If
- Next
- End With
- k1 = d1.keys: t1 = d1.items
- With Sheet3
- .[a3:g5000].ClearContents
- .[a3].Resize(d1.Count) = Application.Transpose(k1)
- .[a3].Resize(d1.Count).TextToColumns DataType:=xlDelimited, Comma:=True
- For i = 0 To UBound(k1)
- t1(i) = Left(t1(i), Len(t1(i)) - 1)
- If InStr(t1(i), ",") Then
- aa = Split(t1(i), ",")
- For jj = 15 To UBound(Arr, 2)
- If jj <> UBound(Arr, 2) - 1 Then
- For j = 0 To UBound(aa)
- .Cells(i + 3, jj - 12) = .Cells(i + 3, jj - 12) + Arr(aa(j), jj)
- Next
- Else
- .Cells(i + 3, jj - 12) = Arr(aa(0), jj)
- End If
- Next
- Else
- For jj = 15 To UBound(Arr, 2)
- If jj <> UBound(Arr, 2) - 1 Then
- For j = 0 To UBound(aa)
- .Cells(i + 3, jj - 12) = .Cells(i + 3, jj - 12) + Arr(t1(i), jj)
- Next
- Else
- .Cells(i + 3, jj - 12) = Arr(t1(i), jj)
- End If
- Next
- End If
- Next
- End With
- Application.DisplayAlerts = True
- End Sub
复制代码 |
|