Ah, sorry if that confused you. I have a habit of breaking long formulas into multiple lines (ALT+ENTER) at logical points so that I find them easier to read.
Code:
=IF(ISNUMBER(MATCH($K$2,$B$1:$H$1,0)),COUNTIF(INDEX($B$2:$H$10,,MATCH($K$2,$B$1:$H$1,0)),J3))
+IF(ISNUMBER(MATCH($K$2,$A$2:$A$10,0)),COUNTIF(INDEX($B$2:$H$10,MATCH($K$2,$A$2:$A$10,0),0),J3))
Glad you've got it sorted now.