Search code examples
excelvbasumifs

VBA sumifs - ignore criteria if not found


Is there a way to create a sumifs function that ignores any criteria that aren't satisfied, and continues to sum based off of the other criteria?

Hope that makes sense...


Solution

  • Your question is a bit short..., but yes it is possible: Put a countif on your Criteria and act when the result of the Countif = 0

    =SUMIFS(C1:C6;A1:A6;IF(COUNTIF(A1:A6;H1)=0;"*";H1);B1:B6;1)
    

    So when Criteria in H1 is not met this is replaced with * so it continues to the other criteria