Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel 如果第一个单元格为空,请执行此操作,否则请执行vba_Excel_Vba_If Statement - Fatal编程技术网

Excel 如果第一个单元格为空,请执行此操作,否则请执行vba

Excel 如果第一个单元格为空,请执行此操作,否则请执行vba,excel,vba,if-statement,Excel,Vba,If Statement,我有以下excel表格: 假设我将在B列上过滤,查找“B” 我们得出以下结果: 我如何进行以下询问: if the first cell after the header is empty(in this case A7) do nothing else do this end if 如何检查标题后的第一个单元格是否为空?因为单元格编号总是不同的。这听起来像是一个错误 另一种方法是在筛选之前使用Application.CountIfs,查看是否存在该标准 If Application.Co

我有以下excel表格:

假设我将在B列上过滤,查找“B”

我们得出以下结果:

我如何进行以下询问:

if the first cell after the header is empty(in this case A7) do nothing
else
do this
end if
如何检查标题后的第一个单元格是否为空?因为单元格编号总是不同的。

这听起来像是一个错误

另一种方法是在筛选之前使用
Application.CountIfs
,查看是否存在该标准

If Application.CountIfs(Range("B:B"), "b") > 0 Then
    ' do the filter
End If
这听起来像是一个错误

另一种方法是在筛选之前使用
Application.CountIfs
,查看是否存在该标准

If Application.CountIfs(Range("B:B"), "b") > 0 Then
    ' do the filter
End If

您可以检查行是否由于应用的筛选器而可见

  • 应用过滤器

  • 从第2行(标题后的第一行)开始,循环工作表的行

  • 要检测第一行可见(未过滤),请执行以下操作:

  • 与空字符串相比,检查第一列中的单元格是否为空:

    If worksheet.Cells(i, 1) = "" Then
    'The first cell is empty
    Else
    'The first cell is not empty
    End If
    

  • 您可以检查行是否由于应用的筛选器而可见

  • 应用过滤器

  • 从第2行(标题后的第一行)开始,循环工作表的行

  • 要检测第一行可见(未过滤),请执行以下操作:

  • 与空字符串相比,检查第一列中的单元格是否为空:

    If worksheet.Cells(i, 1) = "" Then
    'The first cell is empty
    Else
    'The first cell is not empty
    End If
    

  • 在筛选之前,请使用
    Application.CountIfs
    ,查看是否存在标准
    “b”
    。请定义“空”!整数不能为“空”,它是0、1或4711。字符串可以是“”或NULL(在C++中)@BigBen您能给我举个例子吗?
    如果应用程序。CountIfs(范围(“B:B”),“B”)=0,那么
    ?您可以多次使用它并添加结果。在筛选标准
    “B”
    之前,请使用
    应用程序。CountIfs
    。请定义“empty”!整数不能为“空”,它是0、1或4711。字符串可以是“”或NULL(在C++中)@BigBen您能给我举个例子吗?
    如果Application.CountIfs(Range(“B:B”),“B”)=0,那么
    ?您可以多次使用它并添加结果。