|
- Sub qs()
- Dim arr, i, dic, sht As Worksheet
- Set dic = CreateObject("scripting.dictionary")
- ReDim brr(1 To 1000, 1 To 20)
- m = 1: n = 3
- For Each sht In Sheets
- If sht.Name <> "总表" Then
- arr = sht.Range("a1").CurrentRegion.Value
- For i = 3 To UBound(arr)
- s = arr(i, 1): s2 = arr(1, 1)
- If Not dic.exists(s) Then
- m = m + 1
- dic(s) = m
- brr(m, 1) = s
- brr(m, 3) = arr(i, 3)
- Else
- r = dic(s)
- brr(r, 3) = brr(r, 3) + arr(i, 3)
- End If
- If Not dic.exists(s2) Then
- n = n + 1
- dic(s2) = n
- brr(1, n) = s2
- m1 = dic(s)
- brr(m1, n) = brr(m1, n) + arr(i, 3)
- Else
- n2 = dic(s2)
- m2 = dic(s)
- brr(m2, n2) = brr(m2, n2) + arr(i, 3)
- End If
- Next
- End If
- Next
- brr(1, 1) = "名字": brr(1, 2) = "规格": brr(1, 3) = "数量"
- Sheet1.[a2].Resize(m, n) = brr
- End Sub
复制代码 |
评分
-
1
查看全部评分
-
|