- ©«¤l
- 605
- ¥DÃD
- 92
- ºëµØ
- 0
- ¿n¤À
- 648
- ÂI¦W
- 0
- §@·~¨t²Î
- windows
- ³nÅ骩¥»
- 7
- ¾\ŪÅv
- 50
- ©Ê§O
- ¨k
- ¨Ó¦Û
- macau
- µù¥U®É¶¡
- 2013-4-5
- ³Ì«áµn¿ý
- 2019-2-10
|
¦^´_ 18# ML089
MATCH ¥i¥H¥Î Scripting.Dictionary¨Ó¹ê²{
¸Õ¤U±ªºcode- Sub sonny3_dict()
- t1 = Timer
- Dim RowsCnt, m, SubTotalAr() As Double
- Dim DataArea As Variant
- Dim i%, j%
- AllType = Array("AÃþ", "BÃþ", "CÃþ", "DÃþ", "EÃþ", "FÃþ", "GÃþ", "HÃþ", "IÃþ", "JÃþ")
- AllMnth = Array("1¤ë", "2¤ë", "3¤ë", "4¤ë", "5¤ë", "6¤ë", "7¤ë", "8¤ë", "9¤ë", "10¤ë", "11¤ë", "12¤ë")
- ReDim SubTotalAr(0 To UBound(AllType), 0 To 11)
- Set TypeDict = CreateObject("Scripting.Dictionary")
- Set MnthDict = CreateObject("Scripting.Dictionary")
- For i = 0 To UBound(AllType)
- TypeDict(AllType(i)) = i
- Next i
- For i = 0 To UBound(AllMnth)
- TypeDict(AllMnth(i)) = i
- Next i
- Application.ScreenUpdating = False
- With Sheets("ì©l¸ê®Æ")
- RowsCnt = .Range("A1").CurrentRegion.Rows.Count
- DataArea = .Range("A2").Resize(RowsCnt - 1, 3)
- End With
- For m = 1 To UBound(DataArea)
- i = TypeDict(DataArea(m, 1))
- j = MnthDict(Month(DataArea(m, 2)) & "¤ë")
- SubTotalAr(i, j) = SubTotalAr(i, j) + DataArea(m, 3)
- Next m
-
- With Sheets("Á`ªí")
- .Range("B4").Resize(UBound(AllType) + 1, 12) = SubTotalAr
- .Range("B14:R14").FormulaR1C1 = "=SUM(R[-10]C:R[-1]C)"
- .Range("N4:N13").FormulaR1C1 = "=SUM(RC[-12]:RC[-1])"
- .Range("O4:R13").FormulaR1C1 = "=SUM(RC[-13]:RC[-11])"
- End With
- Application.ScreenUpdating = True
- t2 = Timer
- Sheets("ì©l¸ê®Æ").Range("m7") = t2 - t1
- MsgBox "¯Ó®É" & t2 - t1
- End Sub
½Æ»s¥N½X |
|