如何查看Excel中的整个行是否为空白 [英] How to find out if an entire row is blank in excel thorough vba

查看:525
本文介绍了如何查看Excel中的整个行是否为空白的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一张表格,其中有来自两个不同来源的数据。我们之间有一个空行。我想将这个空行作为我的分隔符。如何查看整行是否为空

解决方案

如果你正在说一个文字整行,那么与此相似的代码应该可以工作(只要没有公式或任何单元格中存在的空格):

 如果Application.CountA(ActiveCell.EntireRow)= 0然后
MsgBoxRow Empty
Exit Sub
End If

否则,对于一行的范围:

  Dim neValues As Range,neFormulas As Range,MyRange As Range 

设置MyRange =列(C:AA)

错误恢复下一步
设置neValues =相交(ActiveCell.EntireRow.SpecialCells(xlConstants),MyRange)
设置neFormulas =相交(ActiveCell.EntireRow.SpecialCells(xlFormulas),MyRange)
错误GoTo 0

如果neValues是
MsgBox没有什么
Else
MsgBoxSomething's There
End If

(来源: http://www.ozgrid.com/forum/showthread.php?t=26509&page=1


I have a sheet in which I have data from two different sources.I've a blank row between them.I want to make this blank row as my delimiter.How can I find out if the entire row is blank or not.

解决方案

If you're talking a literal entire row then code similar to this should work (so long as there are no formulas or spaces present in any of the cells as well):

If Application.CountA(ActiveCell.EntireRow)=0 Then
     MsgBox "Row Empty"
     Exit Sub
End If

Otherwise, for a range from a row:

Dim neValues As Range, neFormulas As Range, MyRange As Range

Set MyRange = Columns("C:AA")

On Error Resume Next
Set neValues = Intersect(ActiveCell.EntireRow.SpecialCells(xlConstants), MyRange)
Set neFormulas = Intersect(ActiveCell.EntireRow.SpecialCells(xlFormulas), MyRange)
On Error GoTo 0

If neValues Is Nothing And neFormulas Is Nothing Then
    MsgBox "Nothing There"
Else
    MsgBox "Something's There"
End If

(Source: http://www.ozgrid.com/forum/showthread.php?t=26509&page=1)

这篇关于如何查看Excel中的整个行是否为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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