excel - 如何通过vba找出excel中整行是否为空白

标签 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)

关于excel - 如何通过vba找出excel中整行是否为空白,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3628057/

相关文章:

excel - 如何将 Excel 中的变量标签导入 Stata

excel - 从excel中搜索Access数据库

excel - 使用目标来识别小区位置

vba - 获取 Excel 作为对象附加的 PowerPoint 演示文稿的文件名和路径

vba - Excel - 将占位符与 VBA 中的有效值匹配

excel - 如何将 Power Query 中的两个表与匹配的多个列之一连接起来?

excel - 创建zip错误: Namespace method fails on IShellDispatch

c# - 插入数据后保存excel文件时出现问题

excel - VBA Excel 的正则表达式模式

excel - Outlook 2010 规则是否对从 Excel VBA 发送的邮件运行?