Cell is empty but IsEmpty is not working

廉价感情. 提交于 2019-12-10 16:40:51

问题


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.


回答1:


I prefer using

If Len(Trim(Cells(i, 1).Value))=0 Then Msgbox "Empty"



回答2:


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


来源:https://stackoverflow.com/questions/19105452/cell-is-empty-but-isempty-is-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!