此问题在此处已有答案:
What is the difference between dim and set in vba(7个答案)
10天前关闭。
我得到对象所需运行时错误'424'
Dim LastRowTwo As Long, TargetRange As Variant, ws As Worksheet
Set ws = Sheets("Reconciliation")
TargetRange = ws.Range("B2:B" & LastRowTwo)
With TargetRange
.Formula = "=IFERROR(VLOOKUP(A2, 'ATP Final'!$G:$G, 1, FALSE), ""N/A"")"
.Value = .Value
End With
如何修复此错误?
1条答案
按热度按时间zxlwwiss1#
Targetrange
当前被声明为变量,并且在赋值时缺少Set
关键字。这将导致TargetRange = ws.Range("B2:B" & LastRowTwo)
行隐式添加.value
并将该范围的值加载到二维数组中。您需要实际的范围对象及其所有方法和属性。