且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

单元格为空,但IsEmpty不工作

更新时间:2023-02-13 17:11:02

根据@PatricK的建议,您可以考虑使用ISBLANK功能而不是IsEmpty函数。 ISBLANK 函数如果值为空,则返回TRUE





使用VBA

  Sub test()

对于i = 1至4
MsgBox Evaluate(isblank(& Cells(i,1).Address& ))
下一个

End Sub


I am writing an IF statement that uses the IsEmpty function to determine if True or False. I tried it both on a cell with a value (e.g., PRB2039) and on a blank cell to test my code, and the result is the same.

I removed formatting, and tried it on a new worksheet. I don't know what I'm doing wrong.

As suggested by @PatricK you may consider using ISBLANK function instead of IsEmpty function. ISBLANK function Returns TRUE if the value is blank

Using VBA

Sub test()

    For i = 1 To 4
       MsgBox Evaluate("isblank(" & Cells(i, 1).Address & ")")
    Next

End Sub