Here's what I've settled on. It definitely would not suit everyones' needs.
Situation:
- I don't want to run SUMIF 20 times on 10000 rows
- I can safely assume there will never be more than 200 rows for each category (ie a group of rows that fulfil my sumif criteria).
- It's also useful for me to have a table with only the rows matching that criteria.
Solution:
I create a table with 200 rows of formulas that will display rows that fit my criteria.
The leftmost column will have row number of the next matching row, or be blank and not search if there are no more.
First line of left column:
IFERROR(MATCH(CategoryID,'DataTable'!B:B,0),"")
Subsequent lines of left column (A2 is the cell above):
IF(A2="","",MATCH(CategoryID,OFFSET('DataTable'!B:B,A2,0,RowsInTable-A2,1),0)+A2))
All cells to the right of this are basic INDEX formulas that use the row number from the leftmost column.
To count the number of found results we use:
=COUNTA(A2:A202)-COUNTBLANK(A2:A202)
We then use the this count and the table to perform nice quick SUMs:
SUM(OFFSET(C:C,0,0,RowCount,1))