简体   繁体   English

检查单元格是否为空

[英]Check if cell if empty

I am trying to check if the cell (A5) in sheet tstDash is empty. 我试图检查表tstDash中的单元格(A5)是否为空。 Currently the cell contains a formula but sometimes it the result is blank and sometimes is a number. 目前,单元格包含公式,但有时结果为空白,有时为数字。

If it is blank, I want a message box. 如果它是空白的,我想要一个消息框。 Otherwise perform other function. 否则执行其他功能。

I have this code but it is completely ignoring the line and giving me fits. 我有这个代码,但它完全忽略了这条线,让我适合。

If chk25thPercentile.Checked = True And Globals.tsdDash.Range("A5").Value Is DBNull.Value

尝试这个 ..

If chk25thPercentile.Checked And IsDBNull(Globals.tsdDash.Range("A5").Value)

What language are you writing in ? 你在写什么语言? VBA or VB.Net ? VBA还是VB.Net? VBA won't accept IsDBNull. VBA不接受IsDBNull。 If you are in VBA you want to be testing for the blank result of the formula, which is probably just an empty string "" I expect you need something like 如果你在VBA中,你想要测试公式的空白结果,这可能只是一个空字符串“”我希望你需要像

If chk25thPercentile.Checked And Globals.tsdDash.Range("A5").Value = ""

That is assuming that the result of your formula is an empty string, if the cell is actually blank, ie, without a formula you might want to look at ISBLANK 假设您的公式的结果是空字符串,如果单元格实际上是空白的,即没有公式,您可能需要查看ISBLANK

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

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