Quite often Sumproduct is used in cases where a Pivot table just doesnt cut it. Here's how to make Sumproduct respect filters in a data table.
Lets use the ID column, and make a name range - In this case Im using a data table, but you could equally use a dynamic range.
We are going to leverage the subtotal function , since it respects the rows filtered out in a table, and we can intercept that to create a series of 1/0 to indicate whether the row is filtered or not. To make this very clean , we can create another named range
That gives us this result
You can see that the formula respects any filtering done on the table.
Evaluating the formula shows that the Subtotal() function associated with the respectFilter named range returns a series of 1/0 depending on whether the row is filtered out. It is this behavior that eliminates the hidden rows from the sum.
In the meantime why not join our forum, follow the blog or follow me on twitter to ensure you get updates when they are available.
For more tips like this see Get Started Snippets.
Learning Apps Script, (and transitioning from VBA) are covered comprehensively in my my book, Going Gas - from VBA to Apps script, All formats are available from O'Reilly, Amazon and all good bookshops. You can also read a preview on O'Reilly
Services > Desktop Liberation - the definitive resource for Google Apps Script and Microsoft Office automation > Quirky Functions >