|
本帖最后由 Albert128 于 2012-12-13 23:26 编辑
本人自从接触字典后,就挺感兴趣,现在按字典做法,从不同工作表里,取数据分类汇总,至相应的位置,以下代码不知哪里出现了问题,请各位老师指正,.谢谢!- Sub WholesalesBaraar()
- Dim d As Object, Brr(), i, t, sh, cl, Myr&, cz
- Application.ScreenUpdating = False
- Set d = CreateObject("scripting.dictionary")
- Sheet1.Range("b4:d10").Select
- Selection.ClearContents
- For Each sh In Sheets(Array(Sheet3.Name, Sheet4.Name))
- Myr = sh.[a3].End(xlDown).Row
- Set cz = Sheet1.Range("b3:d3").Find(sh.Name, , , 1)
- If Not cz Is Nothing Then cl = cz.Column - 1
- Arr = sh.Range("a3:l" & Myr).Value
- For i = 1 To UBound(Arr)
- t = d(Arr(i, 11))
- If t = "" Then
- m = m + 1
- d(Arr(i, 11)) = m
- ReDim Brr(m, 1 To 3)
- Brr(m, 1) = Arr(i, 11)
- Brr(m, cl) = Brr(m, cl) + Arr(i, 12)
- Else
- Brr(t, cl) = Brr(t, cl) + Arr(i, 12)
- End If
- Next
- Next
-
- Sheet1.Range("b4").Resize(m, cl) = Brr
- Set d = Nothing
- Application.ScreenUpdating = True
- End Sub
复制代码 |
|