A COUNTIFS() function can do this. =COUNTIFS(A1:Y1,1,B1:Z1,2) Note how the two criteria ranges are the same size but offset by one column.