Sep 5, 2008

How Use SUMIFS(2007) Function in Excel 2003 (UDF SUMIFS2003)

   Hi ! Here Suggest to you

 [ In 2007 Let's Use 2003 SUMIFS ] Let's Look & Find
   Use =SUMIFS2003(SumRange, Range,Condition, Range,Condition...)
10 
11 
12 
13 
14 
15 
16 
17 
18 
19 
20 
21 
22 
23 
24 
25 
26 
ABCGHI
NameWorkedBonusCondition 1Condition 2Condition 3
KimHomes100Kimhomes200
SamBranch110SummaryCheck
ManOffice120320320TRUE
KKoHomes130320320TRUE
KimBranch14000TRUE
SamOffice150500500TRUE
ManHomes160500500TRUE
KKoBranch17000TRUE
KimOffice180460460TRUE
SamHomes190460460TRUE
ManBranch20000TRUE
KKoOffice210320320TRUE
KimHomes220320320TRUE
SamBranch230420420TRUE
KKoBranch290420420TRUE
2600

Used Formula ...(With Running MicrosoftExcel Ver 2003)
NoAddr'  If use below Formula, You'll Get Result as RightResultEtc
1C26=SUM(C11:C25)2600
2G13=SUMPRODUCT(($A$11:$A$25=G11)*($B$11:$B$25=H11),$C$11:$C$25)320
3G14=SUMPRODUCT(($A$11:$A$25="Kim")*($B$11:$B$25="Homes"),$C$11:$C$25)320
4G15=SUMPRODUCT(($A$11:$A$25="=G11")*($B$11:$B$25="=H11"),$C$11:$C$25)0
5G16=SUMPRODUCT(($A$11:$A$25=G11)*($B$11:$B$25>=H11),$C$11:$C$25)500
6G17=SUMPRODUCT(($A$11:$A$25="Kim")*($B$11:$B$25>="Homes"),$C$11:$C$25)500
7G18=SUMPRODUCT(($A$11:$A$25="=G11")*($B$11:$B$25>="=H11"),$C$11:$C$25)0
8G19=SUMPRODUCT(($A$11:$A$25=G11)*($B$11:$B$25< =H11),$C$11:$C$25)460
9G20=SUMPRODUCT(($A$11:$A$25="Kim")*($B$11:$B$25< ="Homes"),$C$11:$C$25)460
10G21=SUMPRODUCT(($A$11:$A$25="=G11")*($B$11:$B$25< ="=H11"),$C$11:$C$25)0
11G22=SUMPRODUCT(($A$11:$A$25=G11)*($B$11:$B$25< >H11),$C$11:$C$25)320
12G23=SUMPRODUCT(($A$11:$A$25="Kim")*($B$11:$B$25< >"Homes"),$C$11:$C$25)320
13G24=SUMPRODUCT(($A$11:$A$25=G11)*($C$11:$C$25< =200),$C$11:$C$25)420
14G25=SUMPRODUCT(($A$11:$A$25=G11)*($C$11:$C$25< =I11),$C$11:$C$25)420
15H13=SUMIFS2003($C$11:$C$25,$A$11:$A$25,G11,$B$11:$B$25,H11)320
16H14=SUMIFS2003($C$11:$C$25,$A$11:$A$25,"Kim",$B$11:$B$25,"Homes")320
17H15=SUMIFS2003($C$11:$C$25,$A$11:$A$25,"=G11",$B$11:$B$25,"=H11")0
18H16=SUMIFS2003($C$11:$C$25,$A$11:$A$25,G11,$B$11:$B$25,">="&H11)500
19H17=SUMIFS2003($C$11:$C$25,$A$11:$A$25,"Kim",$B$11:$B$25,">=Homes")500
20H18=SUMIFS2003($C$11:$C$25,$A$11:$A$25,"=G11",$B$11:$B$25,">="&"H11")0
21H19=SUMIFS2003($C$11:$C$25,$A$11:$A$25,G11,$B$11:$B$25,"< ="&H11)460
22H20=SUMIFS2003($C$11:$C$25,$A$11:$A$25,"Kim",$B$11:$B$25,"< =Homes")460
23H21=SUMIFS2003($C$11:$C$25,$A$11:$A$25,"=G11",$B$11:$B$25,"< ="&"H11")0
24H22=SUMIFS2003($C$11:$C$25,$A$11:$A$25,G11,$B$11:$B$25,"< >"&H11)320
25H23=SUMIFS2003($C$11:$C$25,$A$11:$A$25,"Kim",$B$11:$B$25,"< >Homes")320
26H24=SUMIFS2003($C$11:$C$25,$A$11:$A$25,G11,$C$11:$C$25,"< =200")420
27H25=SUMIFS2003($C$11:$C$25,$A$11:$A$25,"Kim",$C$11:$C$25,"< ="&I11)420
28I13=G13=H13TRUE
29 I13  His Formula Used This Cell  -> I13:I25

     if Formula occurs Error! or Different Result...Check or Remove the Space in Formula.

      How about this suggest?

In 2007 Let's Use 2003 SUMIFS
Use  =SUMIFS2003(SumRangeRange,Condition, Range,Condition...)

Function SUMIFS2003(sumarr As RangeParamArray var() As Variant)
On Error Resume Next
Dim i7 As Double, LB As Double, UB As Double
Dim adr As Variant
     LB = LBound(var)
     UB = UBound(var)
If UB Mod 2 = 0 Then
     SUMIFS2003 = "Sum / Condition1,2 / 3,4"
     Exit Function
End If
ReDim adr(LB To UB)
For i7 = LB To UB Step 2
     adr(i7) = RT(var(i7), var(i7 + 1))
Next
     adr(0) = RT(sumarr, "") & adr(0)
     
SUMIFS2003 = "=SUMPRODUCT(--(" & Join(adr, "),--(") & ")"
For i7 = LB To UB
     SUMIFS2003 = Replace(SUMIFS2003, "--(),", "")
Next
     SUMIFS2003 = Replace(SUMIFS2003, ",--()", ")")
     SUMIFS2003 = Application.Evaluate(SUMIFS2003)
End Function


Function RT(vv, cc)
On Error Resume Next
RT = Application.Evaluate(cc)
If CStr(cc) = "" Then
          RT = "" & vv.Address(External:=True) & "),--("
Else
     If Not (IsError(RT)) Then
          If IsEmpty(RT) Then
               RT = vv.Address(External:=True) & "=""" & cc & """"
          ElseIf IsNumeric(RT) Then
               RT = vv.Address(External:=True) & "=" & cc
          ElseIf IsDate(RT) Then
               RT = vv.Address(External:=True) & "=" & cc
          ElseIf TypeName(Range(cc)) = "RangeThen
               If IsNumeric(RT) Then
                    RT = vv.Address(External:=True) & "=" & cc
               Else
                    RT = vv.Address(External:=True) & "=""" & cc & """"
               End If
          Else
               If IsNumeric(RT) Then
                    RT = vv.Address(External:=True) & RT
               ElseIf IsDate(RT) Then
                    RT = vv.Address(External:=True) & RT
               Else
                    RT = vv.Address(External:=True) & "=""" & RT & """"
               End If
          End If
     Else
     Select Case RT
          Case CVErr(xlErrDiv0):   GoTo ers
          Case CVErr(xlErrNA):     GoTo ers
          Case CVErr(xlErrName):   GoTo ers
          Case CVErr(xlErrNull):   GoTo ers
          Case CVErr(xlErrNum):    GoTo ers
          Case CVErr(xlErrRef):    GoTo ers
          Case CVErr(xlErrValue):  GoTo ers
     End Select
     End If
End If
Exit Function
ers:
If Err.Number = 13 Then
     RT = "--(" & vv.Address(External:=True) & "),"""" & cc & """""
Else
     If IsNumeric(cc) Then
          RT = vv.Address(External:=True) & "=" & cc
     Else
          RT = vv.Address(External:=True) & GetRT(cc)
     End If
End If
End Function

Function GetRT(RTstr)
Dim RTtemp1     As String
Dim RTtemp2    As String
Dim RTLeft     As String
     RTLeft = Left(RTstr, 1)
     RTtemp1 = Mid(RTstr, 2)
     RTtemp2 = Mid(RTtemp1, 2)
If IsNumeric(RTtemp1) Then
ElseIf IsDate(RTtemp1) Then
Else
     RTtemp1 = """" & RTtemp1 & """"
End If

If IsNumeric(RTtemp2) Then
ElseIf IsDate(RTtemp2) Then
Else
     RTtemp2 = """" & RTtemp2 & """"
End If

Select Case Left(RTstr, 2)
Case ">=":     GetRT = ">=" & RTtemp2
Case "=>":     GetRT = ">=" & RTtemp2
Case "<=":     GetRT = "<=" & RTtemp2
Case "=<":     GetRT = "<=" & RTtemp2
Case "<>":     GetRT = "<>" & RTtemp2
Case Else
     Select Case RTLeft
     Case "=": GetRT = "=" & RTtemp1
     Case ">": GetRT = ">" & RTtemp1
     Case "<": GetRT = "<" & RTtemp1
     Case Else
          If IsNumeric(RTstr) Then
               GetRT = "=" & RTstr
          Else
               GetRT = "=""" & RTstr & """"
          End If
     End Select
End Select
End Function

Any Bug Or Ask ... Mail Or Post Reply

No comments:

Locations of visitors to this page