VBA for Excel中的零与空白单元格检查 [英] Zero vs. blank cell check in VBA for Excel

查看:244
本文介绍了VBA for Excel中的零与空白单元格检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个excel电子表格,其中一行中的行数为零(数量),而某些行包含文本子标题,其中数量单元格为BLANK。

I have an excel spreadsheet that can have a number of rows with a zero in one column (quantity) and some rows with text subheaders where the quantity cell is BLANK.

我正在尝试开发一个宏来删除数量单元格为零的行,但它也会删除子标题行。在我看来,我正在做的简单测试不区分零和空白。

I'm trying to develop a macro to delete the rows where the quantity cell is zero but it also deletes the subheader row. It seems to me that the simple test I'm doing does not discriminate between zero and blank.

如果工作表(1).Cells(lnRowCount,10)= 0然后

                     rnSelection.Rows(lnRowCount)。删除

If Worksheets(1).Cells(lnRowCount, 10) = 0 Then
                    rnSelection.Rows(lnRowCount).Delete

有没有更好的检查方法来执行此操作。我猜几个嵌套的IF可能会起作用:

Is there a better check method to do this. I guess a couple of nested IFs might work:

如果Isblank然后跳过else,如果为零则删除。

If Isblank then skip else if zero then delete.

有更优雅的方式吗?

推荐答案

此论坛是关于基于.Net的独立版本
Visual Basic
。请改为查看此论坛:
$
http:// social .msdn.microsoft.com /论坛/ en-US / exceldev / threads


This forum is about the .Net based standalone versions of Visual Basic. Please have a look at this forum instead:
http://social.msdn.microsoft.com/Forums/en-US/exceldev/threads


这篇关于VBA for Excel中的零与空白单元格检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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