$B5:$H5 has the columns locked, so that the formula can be copied across.

K$4 has the row locked so that the formula can be copied down.

All values in the range B5:H5 are compared to the value in K4.

Excel formula: Sum every nth column

Only the values in the second array that correspond to 1s in the first array survive this operation.

This represents the numbers that correspond to “A'” in row 5.

Excel SUMPRODUCT function