VBA VLookupvariables错误

下午好,

我试图写一个worksheet_changemacros,它将使用VLookup通过简单地input项目编号来填充项目描述和构build时间。 有两个单独的表。 第一张是我input物品编号的地方,第二张是我要转移的相关信息。

下面是我现在用于vlookup的代码:

description = Application.WorksheetFunction.VLookup(103770, _ sheet.Range(sheet.Cells(2, 1), sheet.Cells(2000, 9)), 2, False) 

当我手动input“103770”项目编号时,该过程正常工作,但是当我将其更改为variables时,出现错误。 这是插入variables的代码:

 description = Application.WorksheetFunction.VLookup(ERP, _ sheet.Range(sheet.Cells(2, 1), sheet.Cells(2000, 9)), 2, False) 

我把variablesERP变成一个string。 在逐步完成程序并logging本地窗口时,ERP被定义为“103770”。 任何帮助将不胜感激。

先谢谢你!