Well my first whack would be to slap a helper column on the end to do a simple Boolean go/nogo, and then throw the data into a Pivot Table, and then Filter the PT by the helper column.

But formulatically building a table of data would be a lot rougher, I wouldn't do it unless it was really necessary, because you might end up using some dark magic.

Can you post an example spreadsheet?