indexingexcel-formulamatch

Can you skip blank rows in a XMATCH lookup so #N/A is not returned?


I have an Excel workbook where I am extracting totals from monthly worksheets to a master sheet. I use the INDEX + XMATCH method as per the formula below:

    =IFERROR(INDEX(Jul2024Totals,XMATCH(ConsolCodes,Jul2024Codes,0)), "$0.00")

where I XMATCH the master worksheet codes in a column range I have named ConsolCodes with the monthly codes, in another column I have named July2024Codes, where I return the INDEXed totals from July2024Totals. This works fine except where there are blank cells in each of the MATCHED code named ranges. Sure, I can do error trapping to return a NULL value but this only applies to non-matched values and not BLANK cell values. Is there some way to avoid this, like perhaps an IF statement wrapping around the formula, which I have tried but still get a return of #N/A. So either this is not possible or maybe there is some other method?


Solution

  • By checking blanks in ConsolCodes first:

    =IF(ISBLANK(ConsolCodes),0, IFERROR(INDEX(Jul2024Totals,XMATCH(ConsolCodes,Jul2024Codes,0)), 0))
    

    Result