[英]Finding the first specific value above a certain cell
I'm looking for a way to find the first specific value above a certain cell. 我正在寻找一种方法来找到特定细胞上方的第一个特定值。 Using the example below, in the result column every time I hit a A in COL2, I need to substract the value in COL1 to the first A value above.
使用下面的例子,每次我在COL2中点击A时,在结果列中,我需要将COL1中的值减去上面的第一个A值。
The trouble seems finding a way to keep the range dynamic... I thought of =IF(B5="A";A5-INDIRECT("A"&MATCH("A";B:B;0));"")
问题似乎找到一种方法来保持范围动态...我想到
=IF(B5="A";A5-INDIRECT("A"&MATCH("A";B:B;0));"")
But of course that only works for the first one as Match will always pick up the first one. 但是当然这只适用于第一个,因为匹配将总是拿起第一个。
Any ideas? 有任何想法吗? Thanks!
谢谢!
Example : 示例:
COL1 COL2 Result
1 A
2 0
3 0
4 A 4 - 1 = 3
5 0
6 A 6 - 4 = 2
7 0
8 0
9 0
10 A 10 - 6 = 4
=IF(B2="A",A2-INDIRECT("A"&MATCH("A"&(E2-1),F:F,0)),"")
=IF(B2="A",A2-INDIRECT("A"&MATCH("A"&(E2-1),F:F,0)),"")
=IF(B2="a",COUNTIFS($B$2:B2,"a"),"")
=IF(B2="a",COUNTIFS($B$2:B2,"a"),"")
=B2&E2
=B2&E2
Column D is the result you're looking for D列是您正在寻找的结果
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.