这是我的功能:
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
foundID = Application.WorksheetFunction.Match(offline.ListColumns(1).Range(i), oldOut.ListColumns(1).DataBodyRange, 0)
If foundID = 0 Then
foundID = Application.WorksheetFunction.Match(offline.ListColumns(1).Range(i), valComp.ListColumns(1).DataBodyRange, 0)
End If
If foundID = 0 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
foundID = 0
End If
Next i
End Function
我在此行收到“无效的过程调用或参数”错误:
foundID = Application.WorksheetFunction.Match(offline.ListColumns(1).Range(i), oldOut.ListColumns(1).DataBodyRange, 0)
如果它是有用的,该行代码被检查的ID已经不另一个表中存在,因此offline
和oldOut
被声明为在模块的顶部ListObjects。
我以前从未遇到过此错误,并且似乎无法在线找到太多信息。有任何想法吗?
您可能会发现DataBodyRange
inoldOut.ListColumns(1).DataBodyRange
不存在。
如果测试oldOut.ListColumns(1).DataBodyRange.Address
返回的对象未设置错误,那么肯定是问题所在。
我可以重现错误的唯一方法是删除DataBodyRange
或删除表。否则,代码可以正常工作。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句