- ©«¤l
- 4901
- ¥DÃD
- 44
- ºëµØ
- 24
- ¿n¤À
- 4916
- ÂI¦W
- 247
- §@·~¨t²Î
- Windows 7
- ³nÅ骩¥»
- Office 20xx
- ¾\ŪÅv
- 150
- ©Ê§O
- ¨k
- ¨Ó¦Û
- ¥x¥_
- µù¥U®É¶¡
- 2010-4-30
- ³Ì«áµn¿ý
- 2024-11-14
|
¥»©«³Ì«á¥Ñ Hsieh ©ó 2011-12-25 16:13 ½s¿è
¦^´_ 1# idsmchow
³oÓ°ÝÃD¦b2007ª©¥»¥H«á´N«Ü²³æ¥ÎSUMIFS¨ç¼Æ¿ý»s¥¨¶°§Y¥i
2003ª©´N¼gÓ¦h±ø¥ó¥[Á`¨ç¼Æ¨Ó¹B¥Î
¤@¯ë¼Ò²Õ- Function SumIIF(SumRange As Range, ParamArray OtherArgs())'¦h±ø¥ó¥[Á`¨ç¼Æ¡A¥iª½±µ¹B¥Î¨ìÀx¦s®æ
- '»yªk:SumIIF(SumRange,·Ç«h1,·Ç«h½d³ò1,·Ç«h2,·Ç«h½d³ò2,·Ç«h3,·Ç«h½d³ò3...·Ç«hn,·Ç«h½d³òn)
- '·Ç«h½d³ò¤j¤p¥²¶·»PSumRange½d³ò¤j¤p¬Û¦P
- Dim mystr$, temp$
- Set dic = CreateObject("Scripting.Dictionary")
- For i = LBound(OtherArgs) To UBound(OtherArgs) Step 2
- If mystr = "" Then mystr = OtherArgs(i) Else mystr = mystr & OtherArgs(i)
- dic(i + 1) = ""
- Next
- For i = 1 To SumRange.Count
- For Each ky In dic.keys
- If temp = "" Then temp = OtherArgs(ky)(i) Else temp = temp & OtherArgs(ky)(i)
- Next
- If temp = mystr Then SumIIF = SumIIF + SumRange(i)
- temp = ""
- Next
- End Function
- Sub ex()'¥Dµ{¦¡
- Dim Sr As Range
- With Sheets("Data")
- Set Sr = .Range("C2", .[C2].End(xlDown))
- Set cr1 = .Range("A2").Resize(Sr.Count, 1)
- Set cr2 = .Range("B2").Resize(Sr.Count, 1)
- End With
- With Sheets("Report")
- For Each c In .[E8:F8]
- For Each a In .Range("A:A").SpecialCells(xlCellTypeConstants)
- If a = "Y" Then .Cells(a.Row, c.Column) = SumIIF(Sr, c, cr1, a.Offset(, 1), cr2)
- Next
- Next
- End With
- End Sub
½Æ»s¥N½X
formular.rar (11.79 KB)
|
|