Thread: Sumif in 3d
View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Beeblebrox[_2_] Beeblebrox[_2_] is offline
external usenet poster
 
Posts: 1
Default Sumif in 3d


Here's the coding I used. I'm testing conditions that are the text
results of a lookup and summing cells that are numerical results of
nested IF statements and a lookup). But I also tried it with replacing
the text lookup with straight text and the If formulas with numbers on
only three sheets. Still no luck.



Function SumIf3D(Range3D As String, Criteria As String, Optional
Sum_Range As Variant) As Variant

Dim sTestRange As String
Dim sSumRange As String
Dim Sheet1 As Integer
Dim Sheet2 As Integer
Dim n As Integer
Dim Sum As Double

Application.Volatile

If Parse3DRange(Application.Caller.Parent.Parent.Name , Range3D,
Sheet1, Sheet2, Sheet3, sTestRange) = False Then
SumIf3D = CVErr(xlErrRef)
End If

If IsMissing(Sum_Range) Then
sSumRange = sTestRange
Else
sSumRange = Sum_Range.Address
End If

Sum = 0
For n = Sheet1 To Sheet3
With Worksheets(n)
Sum = Sum +
Application.WorksheetFunction.SumIf(.Range(sTestRa nge), Criteria,
..Range(sSumRange))
End With
Next n
SumIf3D = Sum
End Function


--
Beeblebrox
------------------------------------------------------------------------
Beeblebrox's Profile: http://www.excelforum.com/member.php...o&userid=37348
View this thread: http://www.excelforum.com/showthread...hreadid=571630