Home » excel » Excel SUM range of cells based on two delimiting values of another range

# Excel SUM range of cells based on two delimiting values of another range

Questions:

My problem:

I have the below tables:

In my second table (tbl_analysis), I need to create a formula in the Sum column that will sum the salary of a certain person over a certain period. When the period changes, the formula needs to be recalculated.

My try:

I started off by using the formula:

=SUM(my_range)

By the range can’t be hard-coded, so I decided to find the cell address of the corresponding month as you can see in the range D12:E15

Formula in the cell D12:

So when I tried to insert the above formula inside of the SUM formula like this:

And then Excel is referecing the cell address itself and not the address inside of the formula.

Skip the Addresses and use this based on the months:

``````=SUM(INDEX(A:M,MATCH(A12,A:A,0),MATCH(B12,\$2:\$2,0)):INDEX(A:M,MATCH(A12,A:A,0),MATCH(C12,\$2:\$2,0)))
``````

Scott Craner has the right solution for this scenario and it makes more sense here. However if you would absolutely need to get cell reference from a cell you would be able to do it using the following function:

``````INDIRECT(cell)
``````

Usually this isn’t necessary but it can be handy when you want to break up a long formula where you would need to find a row number for example.

``````INDIRECT("A" & B2)
``````

Where B2 has the row number for a dynamic range or specific moving target row.

INDIRECT function documentation