Search code examples
excelexcel-formulasumsumifssumproduct

SUM if header row dones't contain a substring AND range doesn't contain #N/A


In Column A I want to sum all the cells in range B2:J2 that their header row doesn't contain the word "Price", also one of the cells in range B2:J2 might be #N/A.

In the example I shared only the cells that are highlighted in grey are relevant, and the formula should return 5.

I would love to get your help.

attached image


Solution

  • You can use array formula with SUM:

    =SUM(IFERROR(NOT(ISNUMBER(SEARCH("price",$B$1:$J$1)))*(B2:J2),0))
    

    Array formula after editing is confirmed by pressing ctrl + shift + enter

    enter image description here