Countifs循环工作一次,然后停止并抛出运行时错误1004

时间:2019-06-13 09:06:51

标签: excel vba

我正在制作一个主列表,其中包含来自各个工作表的数据,其中一部分需要计数。该代码在第一次迭代中运行没有问题,然后在下次迭代中运行,因此引发运行时错误1004。无法获取WorksheetFunction类的CountIfs属性。

我尝试通过确保所有活动工作表都相同并且仍然没有改变的唯一方法是i ...这是迭代值,它表示要搜索的值以及将其存储在何处,

For i = 2 to rowsHG
Hintergrund.Cells(i + 1, 2) = Application.WorksheetFunction.CountIfs(Arbeitsblatt.Range(Arbeitsblatt.Cells(i, 2), Arbeitsblatt.Cells(RowsAB, 2)), "work", _
        Arbeitsblatt.Range(Arbeitsblatt.Cells(2, 7), Arbeitsblatt.Cells(RowsAB, 7)), Hintergrund.Cells(i + 1, 1), _
        Arbeitsblatt.Range(Arbeitsblatt.Cells(2, 6), Arbeitsblatt.Cells(RowsAB, 6)), "sand")
next i

Hintergrund是新数据的存储地,并且Arbeitsblatt包含信息。 RowsAB是否。 Arbeitsblatt中的行数。当我是2时,一切正常,当它切换到3时,运行时错误1004无法获取WorksheetFunction类的CountIfs属性。

0 个答案:

没有答案
相关问题