Search code examples
excelexcel-formulasumifs

SUMIF formula based on non-contiguous ranges


I have to populate a cash-flow forecast, dependent on dates between the programme and a spend profile matching. Usually I would do this with SUMIF, using two rows for each element of the cost estimate (stacking the '1st' date of the month above the cost). However, I need to perform all of the calculations for this project in the same row. Is it possible?

I have tried to liberate solutions to similar queries (using SUMPRODUCT, OFFSET, INDEX etc), but I am never able to get the correct result. This may be due my lack of ability to doctor them, rather than these functions failing to provide the solution I need.

Ideally, I would like to formulate the following. "IF the date in every 5th column in the Spend Profile range matches the date in row 2 of the Programme range, SUM the value(s) in the cell(s) 2 columns prior".

The image below shows a very scaled down version of the data I have to work with. I have manually entered the expected results in the Programme range to illustrate the desired result. nb. CELLS G4 and L4 match S2, therefore E4 and J4 are returned.

Sample Data: Scaled down


Solution

  • You can make it work with SUMIFS with your sample data by offsetting the ranges like this

    =SUMIFS($A4:$O4,$C2:$Q2,"1st",$C4:$Q4,S$2)
    

    enter image description here