By checking blanks in ConsolCodes first:
ConsolCodes
=IF(ISBLANK(ConsolCodes),0, IFERROR(INDEX(Jul2024Totals,XMATCH(ConsolCodes,Jul2024Codes,0)), 0))