GeekGirlau
Programmer
I've had a look at the posts re SumProduct with a wildcard, but my problem is a little different.
I have some criteria that may be blank, in which case I don't want them included in the SumProduct at all.
My actual SumProduct formula requires an additional 3-4 criteria, but I've shortened it in the examples below. The ranges critSupplier and critCategory may all be filled, may all be blank, or either of them may be blank.
Neither of the following work:
=SUMPRODUCT(IF(critSupplier<>"", (Vendor=critSupplier),1) * IF(critCategory<>"", (SalesCat=critCategory),1) * Sales2004)
=SUMPRODUCT((Vendor=IF(critSupplier="", "*", critSupplier)) * (SalesCat=IF(critCategory="", "*", critCategory)) * Sales2004)
I know I can have a nasty formula such as the following:
=IF(AND(critSupplier="",critCategory=""), SUMPRODUCT(Sales2004), IF(critSupplier="",SUMPRODUCT((SalesCat=critCategory) * Sales2004), IF(critCategory="",SUMPRODUCT((Vendor=critSupplier) * (SalesCat=critCategory) * Sales2004),SUMPRODUCT((Vendor=critSupplier) * (SalesCat=critCategory) * Sales2004))))
but I was hoping for a more elegant (and shorter!) solution - any ideas?
I have some criteria that may be blank, in which case I don't want them included in the SumProduct at all.
My actual SumProduct formula requires an additional 3-4 criteria, but I've shortened it in the examples below. The ranges critSupplier and critCategory may all be filled, may all be blank, or either of them may be blank.
Neither of the following work:
=SUMPRODUCT(IF(critSupplier<>"", (Vendor=critSupplier),1) * IF(critCategory<>"", (SalesCat=critCategory),1) * Sales2004)
=SUMPRODUCT((Vendor=IF(critSupplier="", "*", critSupplier)) * (SalesCat=IF(critCategory="", "*", critCategory)) * Sales2004)
I know I can have a nasty formula such as the following:
=IF(AND(critSupplier="",critCategory=""), SUMPRODUCT(Sales2004), IF(critSupplier="",SUMPRODUCT((SalesCat=critCategory) * Sales2004), IF(critCategory="",SUMPRODUCT((Vendor=critSupplier) * (SalesCat=critCategory) * Sales2004),SUMPRODUCT((Vendor=critSupplier) * (SalesCat=critCategory) * Sales2004))))
but I was hoping for a more elegant (and shorter!) solution - any ideas?