编程技术网

关注微信公众号,定时推送前沿、专业、深度的编程技术资料。

 找回密码
 立即注册

QQ登录

只需一步,快速开始

极客时间

“无效的过程调用或参数";在VBA函数中使用Application.Match时:"Invalid Procedure Call or Argument" when using Application.Match within VBA Function

PallavBakshi 集合 2022-5-11 10:49 5人围观

腾讯云服务器
“无效的过程调用或参数";在VBA函数中使用Application.Match时的处理方法

这是我的功能:

Function stageValueVariance(stage As String, valCol As Long) For i = 2 To offlineHeight If Application.VLookup(offline.ListColumns(1).Range(i).value, bce.DataBodyRange, valCol, 0) <> offline.ListColumns(valCol).Range(i).value Then found oldOut.ListColumns(1).DataBodyRange, 0) If found Then found valComp.ListColumns(1).DataBodyRange, 0) End If If found Then With stageValComp.ListRows.Add .Range(1) = offline.ListColumns(1).Range(i) .Range(2) = offline.ListColumns(2).Range(i) .Range(3) = stage .Range(4) = offline.ListColumns(7).Range(i) .Range(5) = Application.VLookup(offline.ListColumns(1).Range(i).value, bce.DataBodyRange, valCol, 0) .Range(6).Validation.Add Type:=xlValidateList, AlertStyle:=xlValidAlertStop, Formula1:="Yes, No" End With End If found End If Next i End Function 

我在此行收到无效的过程调用或参数"错误:

I'm getting the 'Invalid Procedure Call or Argument' error on this line:

found oldOut.ListColumns(1).DataBodyRange, 0) 

如果有用,该行代码将检查另一个表中是否已存在ID,因此将 offline oldOut 声明为顶部的ListObjects模块的

If it's useful, that line of code is checking that an ID doesn't already exist within another table, so offline and oldOut are declared as ListObjects at the top of the module.

我以前从未遇到过此错误,并且似乎无法在线找到太多信息.有什么想法吗?

I've never come across this error before, and can't seem to find much information online. Any ideas?

问题解答

您可能会在 oldOut.ListColumns(1).DataBodyRange 中不存在 DataBodyRange

如果测试 oldOut.ListColumns(1).DataBodyRange.Address 返回的对象未设置错误,那么这肯定是问题.

If testing oldOut.ListColumns(1).DataBodyRange.Address returns an object not set error then this is definitely the problem.

唯一可以重现错误的方法是删除 DataBodyRange 或删除表.否则代码可以正常工作.

The only way I can reproduce your error is by deleting the DataBodyRange or by deleting the table. Code works fine otherwise.

这篇关于“无效的过程调用或参数";在VBA函数中使用Application.Match时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程技术网(www.editcode.net)!

腾讯云服务器 阿里云服务器
关注微信
^