|
- Sub cs()
- Dim arr(1 To 999, 1 To 4)
- With Sheet1.UsedRange.Resize(, 3).Offset(2, 1)
- .ClearContents
- aa = .Value
- End With
- Set dic = CreateObject("scripting.dictionary")
- For Each sh In Sheets
- If sh.Name Like "姓名*" Then
- With sh
- tmp = .UsedRange.Offset(3, 1).Resize(, 34)
- For i = 1 To UBound(tmp) - 3
- If Len(tmp(i, 1)) Then
- If dic.exists(tmp(i, 1)) Then
- p = dic(tmp(i, 1))
- Else
- n = n + 1
- dic(tmp(i, 1)) = n
- p = n
- arr(p, 1) = tmp(i, 1) '名称
- arr(p, 3) = tmp(i, 34) '单价
- End If
- For j = 2 To 32
- arr(p, 2) = arr(p, 2) + tmp(i, j) '数量累计
- Next
- End If
- Next
- End With
- End If
- Next
- For i = 1 To n
- arr(i, 4) = arr(i, 2) * arr(i, 3) '总价
- Next
- Sheet1.[b3].Resize(n, 4) = arr
- End Sub
复制代码 |
|