View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
L. Howard L. Howard is offline
external usenet poster
 
Posts: 852
Default SUMIFS ? for multiple ranges

On Friday, April 10, 2015 at 7:21:10 AM UTC-7, Claus Busch wrote:
Hi Howard,

Am Thu, 9 Apr 2015 22:54:47 -0700 (PDT) schrieb L. Howard:

This will do, and if there were too many of these ranges I suppose one could resort to code.


if your table layout is always one column with characters, one with
digits and one blank and so on, you could use this UDF:

Function mySumIf(myRng As Range, strCheck As String) As Double
Dim i As Long, j As Long
Dim varData As Variant

varData = myRng

For i = 1 To UBound(varData)
For j = 1 To myRng.Columns.Count - 1 Step 3
If varData(i, j) = strCheck Then
mySumIf = mySumIf + varData(i, j + 1)
End If
Next
Next
End Function

And call the function in the sheet with
=mySumIf(A1:K8,"C")
or
=mySumIf(A1:K8,A3) if C is in A3


Regards
Claus B.
--


Indeed! Very clever.

Thanks.
Howard