|
不知你怎樣衹刪D列, 先給你匯出來, 你自行修改。
- Sub zz()
- Dim ar, r As Object, d As Object, k, t
- Set d = CreateObject("scripting.dictionary")
- Set r = CreateObject("vbscript.regexp")
- ar = Range("C6:e" & [e1048576].End(3).Row).Value
- With r
- .Pattern = "-[^\w]+$"
- For i = 1 To UBound(ar)
- If ar(i, 2) = "END" Then Exit For
- k = ar(i, 1) & "|" & .Replace(ar(i, 2), "")
- If Not d.exists(k) Then
- d(k) = ar(i, 3)
- Else
- d(k) = d(k) + ar(i, 3)
- End If
- Next
- ReDim ar(1 To d.Count, 1 To 3)
- k = d.keys
- For i = 0 To UBound(k)
- t = Split(k(i), "|")
- For j = 0 To 1
- ar(i + 1, j + 1) = t(j)
- Next
- ar(i + 1, 3) = d(k(i))
- Next
- Workbooks.Add 1
- [a1].Resize(d.Count, 3) = ar
- End With
- End Sub
复制代码
|
|