从另一个工作簿VLOOKUP,但错误#value

我从用户input,并使用这个input,我从另一个工作簿使用vlookup.However但我无法得到正确的价值,总是#value错误

Option Explicit Sub SıraNo() Dim ResimNo As Long Dim Calc As Integer Dim p As Integer Dim k As Integer Dim n As Integer Dim strVariable As Integer Dim wa As Workbook Dim twb As Workbook Set twb = ThisWorkbook Dim j As Integer Range("A2", Range("A2").End(xlDown)).Select Do If ActiveCell.Value = "" Then Exit Do ActiveCell.Offset(1, 0).Select n = n + 1 Loop p = 2 For k = 1 To n ResimNo = InputBox("Please Enter Resim No") Cells(p, 2).Value = ResimNo strVariable = Left(ResimNo, 4) Cells(p, 3).Value = strVariable If strVariable = 5701 Then Set wa = Workbooks.Open("C:\Users\userpc\Desktop\Gökhan\makro\Teknik Resim Arsiv Listesi_5701.xls") ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$H$1500"), , xlYes).Name = _ "Table1" j = k + 1 With twb.Sheets("Sheet1") .Cells(j, 4) = Application.VlookUp(.Cells(j, 2).Value2, "Table1", 6, False) End With End If p = p + 1 Next k End Sub 

你可以尝试这样的事情…

 Dim tbl As ListObject ActiveSheet.ListObjects.Add(xlSrcRange, Range("$A$1:$H$1500"), , xlYes).Name = _ "Table1" Set tbl = ActiveSheet.ListObjects("Table1") With twb.Sheets("Sheet1") .Cells(j, 4) = Application.VLookup(.Cells(j, 2).Value2, tbl.Range, 6, False) End With