提问人:PYC 提问时间:10/9/2023 最后编辑:Mayukh BhattacharyaPYC 更新时间:10/9/2023 访问量:45
在循环中添加 vlookup 的运行时错误 9
Run-time error 9 for adding vlookup in a loop
问:
我使用以下代码将 vlookup 函数添加到循环中的某个单元格。在一点之后,我得到运行时 9 或 1004。我无法自己处理这个问题。提前非常感谢您的支持。
Private Sub Worksheet_Change(ByVal Target As Range)
Dim V As Range
Dim cell1 As Range
Dim isect1 As Range
Set V = Range("D4:D29")
Set isect1 = Intersect(Target, V)
If isect1 Is Nothing Then
Exit Sub
Else
For Each cell1 In isect1
If cell1.Value <> "" Then
cell1.Offset(0, 1).Value = WorksheetFunction.VLookup(cell1, Workbooks("KV_ENVANTER.xlsm").Sheets("sheet3").Range("D2:E9"), 2, False)
ElseIf IsEmpty(cell1.Value) = True Then
cell1.Offset(0, 1).ClearContents
End If
Next cell1
End If
End Sub
答: 暂无答案
评论