- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 255
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2024-11-24
|
¥»©«³Ì«á¥Ñ Hsieh ©ó 2012-10-11 09:31 ½s¿è
¦^´_ 5# fangsc - Sub ex()
- Dim d As Object, SumColumn$, n$, i%, A As Range, Mystr$, ky As Variant, Ay(), ar()
- Set d = CreateObject("Scripting.Dictionary")
- 10
- SumColumn = InputBox("¿é¤JÄæ¦ì", , "AN")
- If SumColumn = "" Then GoTo 10
- [B1] = SumColumn
- With Sheets("Summary")
- For Each A In .Range(.[A3], .[A2].End(xlDown))
- Mystr = Join(Application.Transpose(Application.Transpose(A.Resize(, 4))), ",")
- d(Mystr) = Array(A.Value, A.Offset(, 1).Value, A.Offset(, 2).Value, A.Offset(, 3).Value, .Cells(A.Row, SumColumn).Value)
- Next
- With Sheets("data")
- For Each A In .Range(.[A2], .Cells(.Rows.Count, 1).End(xlUp))
- If InStr(A.Offset(, 2), "Electro") > 0 Then
- Mystr = A.Offset(, 1) & "," & A.Offset(, 2) & "," & A.Offset(, 3) & "," & A.Offset(, 8)
- If IsEmpty(d(Mystr)) Then
- d(Mystr) = Array(A.Offset(, 1).Value, A.Offset(, 2).Value, A.Offset(, 3).Value, A.Offset(, 8).Value, A.Offset(, 9).Value)
- Else
- ar = d(Mystr)
- ar(UBound(ar)) = ar(UBound(ar)) + A.Offset(, 9)
- d(Mystr) = ar
- End If
- End If
- Next
- End With
- Ay = Application.Transpose(Application.Transpose(d.items))
- .[A3].Resize(d.Count, 4) = Ay
- .Cells(3, SumColumn).Resize(d.Count, 1) = Application.Index(Ay, , 5)
- End With
- End Sub
½Æ»s¥N½X |
|