or maybe so
Sub ttt()
On Error Resume Next
With Range("B5:B27")
    .UnMerge
    .SpecialCells(xlCellTypeBlanks).FormulaR1C1 = "=R[-1]C"
End With
With Range("I7:O10")
    .FormulaR1C1 = "=SUMPRODUCT((R5C2:R27C2=RC8)*(R5C3:R27C3=R6C)*R5C4:R27C4)"
End With
End Sub