在VBA(Excel)中= Empty和IsEmpty()有什么区别? [英] What is the difference between =Empty and IsEmpty() in VBA (Excel)?

查看:3799
本文介绍了在VBA(Excel)中= Empty和IsEmpty()有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用了以下VBA代码:

I have used the following VBA code:

Do While .Cell(i,1) <> Empty
  ' doing things
  i = i+1
Loop

在Excel中迭代列(Double / Integer值)。然后我发现一个情况,当单元格的值为0时,测试评估为False。我不知道这种情况与工作的区别是什么。

to iterate through columns (with Double/Integer values) in Excel. Then I found a case where the test evaluates to False whenever the value of the cell is 0. I have no idea what the difference is between this case and the working ones.

如果我将测试更改为:

Do While Not IsEmpty(.Cell(i,1))
  ..
Loop

它工作正常。所以我的问题是:IsEmpty()和= Empty是否被评估有什么区别?在什么情况下=值为0的单元格的空值为True?

it works fine. So my question is: What is the difference between how IsEmpty() and =Empty is evaluated? In what cases will =Empty evaluate to True for cells with value 0?

推荐答案

是指一个变量处于其默认值。所以如果你检查一个值为0 = 的单元格是否为空,那么它将返回true。

Empty refers to a variable being at its default value. So if you check if a cell with a value of 0 = Empty then it would return true.

IsEmpty 指的是没有初始化值。

IsEmpty refers to no value being initialized.

简而言之,如果你想看看一个单元格是否为空(as在其值中不存在),然后使用 IsEmpty 。如果您想查看某些内容当前是否为默认值,请使用

In a nutshell, if you want to see if a cell is empty (as in nothing exists in its value) then use IsEmpty. If you want to see if something is currently in its default value then use Empty.

这篇关于在VBA(Excel)中= Empty和IsEmpty()有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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