简体   繁体   中英

Excel formula to Find the last cell with value in a row and add to adjacent cell if there aren't blank

I am trying to find a formula in excel which will find the last cell that has a value and then it to check if the adjacent cells have value and if it has values then it should show the sum until it reaches a blank cell in the reverse direction on cell O1 and also should show the count of the cell in P1.

在此处输入图像描述

So, this what I have tried and works, use the below formulas, to accomplish the output you are looking for,

FORMULA_解决方案

• Formula used in cell O2 --> To get the sum of the values from back until a blank has been found towards left.

=SUM(INDEX(B2:M2,MATCH(2,1/ISBLANK(INDEX(B2:M2,1):
INDEX(B2:M2,MATCH(2,B2:M2,1)))))
:INDEX(B2:M2,MATCH(2,B2:M2,1)))

• Formula used in cell P2 --> To get the counts.

=COUNT(INDEX(B2:M2,MATCH(2,1/ISBLANK(INDEX(B2:M2,1):
INDEX(B2:M2,MATCH(2,B2:M2,1))))):
INDEX(B2:M2,MATCH(2,B2:M2,1)))

Note: Array formulas needs to be committed with CTRL + SHIFT + ENTER and fill down

I tried the above however it just returned 1 both on O1 and P1. Am I missing something?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM