本文介绍了检查Excel Range是否包含一个空单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经看到了很多解决方案,但是所有解决方案都包括检查整个范围或检查范围中的特定单元格.
I have seen a bunch of solutions, but all include either checking the whole range or checking a specific cell in a range.
是否可以检查特定范围内的 任何 空单元格?
Is there a way to check if there are any empty cells in a specific range?
这是我当前正在使用的,但是 thisCount
始终为0,即使我知道应该为27(27是占用的单元数).我打开了调试模式,然后看到该范围实际上是我想要的范围.
This is what I am currently using, but thisCount
is always 0, even though I know it should be 27 (27 being the number of occupied cells). I have opened debugging mode to, and I see that the range is in fact the one that I want.
range = xlWorkSheet.Range[xlWorkSheet.Cells[rows][1], xlWorkSheet.Cells[rows][columns]];
double thisCount = this.Application.WorksheetFunction.CountA(range);
推荐答案
如果您有一个漂亮的矩形块,例如 A1:D7 ,则:
If you have a nice rectangular block like A1:D7 then:
=IF(ROWS(A1:D7)*COLUMNS(A1:D7)=COUNTA(A1:D7),"no empties","at least one empty")
在 VBA 中,您将检查 SpecialCells(xlCellTypeBlanks)
这篇关于检查Excel Range是否包含一个空单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!