|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
- Sub ek_sky()
- Dim arr As Variant, brr As Variant, crr As Variant
- Dim dis As Object
- Dim i As Integer, j As Integer, k As Integer, L As Integer, M As Integer
- Set dis = CreateObject("scripting.dictionary")
- With Sheets("清单表")
- arr = .Range("A2:C" & .Cells(.Rows.Count, 1).End(xlUp).Row)
- End With
- ReDim brr(1 To UBound(arr), 1 To 200)
- brr(1, 1) = "日期"
- k = 1: M = 1
- For i = 1 To UBound(arr)
- If Not dis.exists(arr(i, 1)) Then
- k = k + 1
- dis.Add arr(i, 1), k
- brr(k, 1) = arr(i, 1)
- End If
- crr = Split(arr(i, 3), "+")
- For L = 0 To UBound(crr)
- t = Left(crr(L), InStr(crr(L) & "*", "*") - 1)
- If Not dis.exists(t) Then
- M = M + 1
- dis.Add t, M
- brr(1, M) = t
- brr(dis(arr(i, 1)), M) = Val(Mid(crr(L) & "*", InStr(crr(L) & "*", "*") + 1, 15))
- Else
- brr(dis(arr(i, 1)), dis(t)) = brr(dis(arr(i, 1)), dis(t)) + Val(Mid(crr(L) & "*", InStr(crr(L) & "*", "*") + 1, 15))
- End If
- Next L
- Next i
- With Sheets("汇总表")
- .Range("A1").Resize(k, M) = brr
- End With
- End Sub
复制代码 |
|