Search code examples
excelsumoffset

Sum with offset based on Sl No


Sum is to be based on Sl. No field (image attached)

The formula in cells are as follows
E3 : ROUNDUP(D3,-0.1)
E4 : ROUNDUP(D4,-0.1)
E7 : ROUNDUP(SUM(D5:D7),-0.1)
E9 : ROUNDUP(SUM(D8:D9),-0.1)
E10 : ROUNDUP(D10,-0.1)

I wish the sum to be calculated in Col. E.

If there is a value in the next immediate row in Sl. No. field, then the value in Col. D is to be directly displayed after rounding off to next whole number in Col. E. Whenever “” is found below the next serial number, the values from that corresponding cell in Col D should be added till the last cell against which the next serial number is not present. The sum shall be rounded off to next whole number and displayed in Col. E (highlighted) against the last value in Col. D.

User-defined function in Col.E is desirable say sumfunctionrng(B:B, E:E)

Similar problem is mentioned in VBA - conditional Sum column B until change of value in column A


Solution

  • Try this in E3 and fill down.

    =IF(OR(B4<>"", ROW(B3)=MATCH(1E+99, D:D)), CEILING(SUM(D3:INDEX(D:D, MATCH(1E+99, B$1:B3))), 1), "")
    

    enter image description here