vba - 计算行数时出现“对象不支持属性或方法”错误

标签 vba excel

以下代码生成 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/

相关文章:

vba - 填充字典导致错误

VBA - 获取数组长度时限定符无效

vba - 导出到 Excel 两张具有不同名称的工作表

excel - 如何创建具有多个 OR 条件的 if 语句?

excel - MAX + 左函数 Excel

excel - vba 代码给我运行时错误 91 对象变量或未设置 block

excel - 如何点击雅虎财经中的搜索按钮

python - bool 逻辑的模糊真值

c# - 使用 Excel 作为日志阅读器。如果 Excel 打开,如何写入日志文件?

excel - 在用户窗体 VBA 中使用带有选项按钮的 IF/Then 语句