简体   繁体   English

Excel 2013 VBA IsEmpty / HasFormula-概念

[英]Excel 2013 VBA IsEmpty/HasFormula - conceptual

Just starting out with VBA and wanted to ask a conceptual question. 刚开始使用VBA并想提出一个概念性问题。 If I want to check if a cell contains a formula I use the HasFormula PROPERTY, but if I want to know if a cell is empty I use the IsEmpty FUNCTION. 如果要检查单元格是否包含公式,请使用HasFormula属性,但是如果我想知道单元格是否为空,请使用IsEmpty FUNCTION。 To me these seem like two kinds of the same operation. 在我看来,这似乎是两种相同的操作。 Is there a conceptual reason one is a property and the other a function? 有一个概念上的原因,一个是属性,另一个是函数吗?

A cell containing a formula that returns Null will return False from IsEmpty(), but an empty cell will return True : 包含返回Null的公式的单元格将从IsEmpty()返回False ,但空单元格将返回True

Sub HowEmptyIsIt()
    Dim r As Range
    Set r = Range("A1")

    r.Formula = "="""""
    MsgBox IsEmpty(r)
    r.Clear
    MsgBox IsEmpty(r)

End Sub

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

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