如何查看整个行在excel彻底vba中是否空白

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

如果你正在说一整行文字,那么类似这样的代码应该可以工作(只要在任何单元格中都不存在公式或空格):

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

否则,从一行的范围:

 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 

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

WorksheetFunction.CountA() ,如下所示:

 Dim row As Range Dim sheet As Worksheet Set sheet = ActiveSheet For i = 1 To sheet.UsedRange.Rows.Count Set row = sheet.Rows(i) If WorksheetFunction.CountA(row) = 0 Then MsgBox "row " & i & " is empty" End If Next i