以下代码生成 Object does not support this property or method
错误:
With CellsTab
NumOfProdCells = .Range(.Cells(.Match(CurrentStartRow,.Range("MIRCellColumn"), 0), 4),
.Cells(.Match(CurrentStartRow,.Range("MIRCellColumn"), 0), 4).End(xlDown)).Rows.Count
End With
CellsTab
是一个工作表,NumOfProdCell
s 是 long 类型,CurrentStartRow
也是整数,MIRCellColumn
是工作表中的一个命名范围 CellsTab
.
最佳答案
失败是因为 .match
..match
是一个工作簿函数,但您正在使用它,就好像它是工作表的一种方法。而是使用:
With CellsTab
NumOfProdCells = _
.Range(.Cells(Application.WorksheetFunction.Match(CurrentStartRow, _
.Range("MIRCellColumn"), 0), 4), _
.Cells(Application.WorksheetFunction.Match(CurrentStartRow, _
.Range("MIRCellColumn"), 0), 4).End(xlDown)).Rows.Count
End With
关于vba - 计算行数时出现“对象不支持属性或方法”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38491519/