返回值为1的引用单元格为空 [英] Return a value of '1' a referenced cell is empty

查看:192
本文介绍了返回值为1的引用单元格为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Excel中,如果引用的单元格为空,我需要返回 1 的值



我可以

解决方案 / div>

您可以使用:

  = IF(ISBLANK(A1),1,0)

但你应该小心你的意思是空单元格。我以前被抓到了。如果你想知道一个单元格是否真的空白 isblank ,如上所述,将会工作。不幸的是,您有时也需要知道它是否只包含有用的数据。



表达式:

  = IF(ISBLANK(A1),TRUE,(TRIM(A1)=))

将为真正为空白的单元格返回true,否则只包含空格。



A 包含不同数量的空格,列 B 包含长度(所以你知道有多少空格)和列 C 包含上述表达式的结果:

 < -A-& < -B-> < -C-> 
0 TRUE
1 TRUE
2 TRUE
3 TRUE
4 TRUE
5 TRUE
a 1 FALSE
<-A - > < -B-> < -C->

如果单元格为空白或空格则返回1,否则返回0:

  = IF(ISBLANK(A1),1,if(TRIM(A1)=,1,0))

会做的伎俩。



您正在检查的实际上是Excel函数的结果。许多Excel函数(如修剪)将返回一个空字符串,而不是一个空白单元格。



您可以使用新的工作表查看此操作。将单元格 A1 按原样设置,并将 A2 设置为 = trim(a1)

然后将 B1 设置为 = isblank(a1) B2 isblank(a2)。你会看到前者是真实的,而后者是假的。


In Excel, I need to return a value of 1 if a referenced cell is empty

I can do it if the value is zero but how do I do it if it is empty?

解决方案

You can use:

=IF(ISBLANK(A1),1,0)

but you should be careful what you mean by empty cell. I've been caught out by this before. If you want to know if a cell is truly blank, isblank, as above, will work. Unfortunately, you sometimes also need to know if it just contains no useful data.

The expression:

=IF(ISBLANK(A1),TRUE,(TRIM(A1)=""))

will return true for cells that are either truly blank, or contain nothing but white space.

Here's the results when column A contains varying amounts of spaces, column B contains the length (so you know how many spaces) and column C contains the result of the above expression:

<-A-> <-B-> <-C->
        0   TRUE
        1   TRUE
        2   TRUE
        3   TRUE
        4   TRUE
        5   TRUE
  a     1   FALSE
<-A-> <-B-> <-C->

To return 1 if the cell is blank or white space and 0 otherwise:

=IF(ISBLANK(A1),1,if(TRIM(A1)="",1,0))

will do the trick.

This trick comes in handy when the cell that you're checking is actually the result of an Excel function. Many Excel functions (such as trim) will return an empty string rather than a blank cell.

You can see this in action with a new sheet. Leave cell A1 as-is and set A2 to =trim(a1).

Then set B1 to =isblank(a1) and B2 to isblank(a2). You'll see that the former is true while the latter is false.

这篇关于返回值为1的引用单元格为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆