- Sub sum()
- Application.ScreenUpdating = False
- Dim arr, qp(1 To 100000, 1 To 11), crr, i, r, c
- Set d = CreateObject("scripting.dictionary")
- arr = Sheet1.[a1].CurrentRegion
- Sheet2.[a1].CurrentRegion.Offset(1).ClearContents
- For i = 2 To UBound(arr)
- sr = Split(arr(i, 4), ".")(3)
- c = InStr("ip1ip2ip3ip4ip5ip6ip7ip8", sr) / 3'得到qp的列标
- If d.exists(arr(i, 1)) Then
- r = d(arr(i, 1))'得到qp的列标
- Select Case arr(i, 2)
- Case Is = "超时"
- qp(r, c) = arr(i, 2)
- qp(r, 11) = qp(r, 11) + 1
- Case Is = "连接"
- If qp(r, c) = "" Then
- qp(r, c) = arr(i, 2)
- End If
- qp(r, 9) = qp(r, 9) + 1
- Case Is = "中断"
- If qp(r, c) = "" Then
- qp(r, c) = arr(i, 2)
- End If
- qp(r, 10) = qp(r, 10) + 1
- End Select
- Else
- k = k + 1
- d(arr(i, 1)) = k'得到qp的行标
- Select Case arr(i, 2)
- Case Is = "超时"
- qp(k, c) = arr(i, 2)
- qp(k, 11) = qp(k, 11) + 1
- Case Is = "连接"
- If qp(k, c) = "" Then
- qp(k, c) = arr(i, 2)
- End If
- qp(k, 9) = qp(k, 9) + 1
- Case Is = "中断"
- If qp(k, c) = "" Then
- qp(k, c) = arr(i, 2)
- End If
- qp(k, 10) = qp(k, 10) + 1
- End Select
- End If
- Next
- Sheet2.[a2].Resize(d.Count) = Application.Transpose(d.keys)
- Sheet2.[b2].Resize(r, 11) = qp
- Application.ScreenUpdating = True
- End Sub
复制代码 |