简体   繁体   English

Excel-对同一行上单元格的公式引用

[英]Excel - Formula reference to cell on the same row

I'm trying to build a simple formula: if the cell on the same row as current cell, but column J is either =1 or empty, then the result is 1, else 0. 我正在尝试建立一个简单的公式:如果该单元格与当前单元格在同一行,但列J为= 1或为空,则结果为1,否则为0。

The part about =1 works, the part about="" does not for some reason. 关于= 1的部分有效,关于=“”的部分由于某种原因不起作用。

Here is my formula: 这是我的公式:

    =IF(OR("J"&ROW()=1,"J"&ROW()=""),1,0)

Can anyone help me find out why "J"&ROW()="" returns false, even if it is clearly true? 谁能帮助我找出为什么“ J”&ROW()=“”返回false的原因,即使它显然是正确的? The "J"&ROW()=1 returns true if the target cell is 1. 如果目标单元格为1,则“ J”&ROW()= 1返回true。

Another thing i tested is "J"&ROW()=j50, where 50 is the actual row number, and this also returned false, which does not make any sense to me. 我测试的另一件事是“ J”&ROW()= j50,其中50是实际的行号,并且它还返回false,这对我来说没有任何意义。

You need either INDIRECT to turn the string into a cell reference 您需要INDIRECT才能将字符串转换为单元格引用

=IF(OR(INDIRECT("J"&ROW())=1,INDIRECT("J"&ROW())=""),1,0)

or use INDEX (as INDIRECT is volatile) 或使用INDEX(因为INDIRECT易变)

=IF(OR(INDEX(J:J,ROW())=1,INDEX(J:J,ROW())=""),1,0)

In this specific case it makes sense to make use of RC notation. 在这种特定情况下,使用RC符号是有意义的。 A formula would look like this: 公式如下所示:

=IF(OR(RC10=1;RC10="");1;0)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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