=IF(COUNTBLANK(D4:G4=0),(IF(COUNTBLANK(H4:K4=0),(IF(COUNTBLANK(L4:O4=0),"Distinction","Merit","Pass","Not Passed")))))
If certain cells aren't blank then the formula should check if the next set aren't blank and then finally check the last set. If all 3 aren't blank then return Distinction, if...