错误1004 Vlookup VBA

时间:2017-06-29 12:09:28

标签: excel vba

关于VBA,我还有一个问题要问。我目前正在尝试使用VLookUp功能。以下是与代码相关的所有信息:

Dim Template_Sheet As Worksheet
Dim Database_Sheet As Worksheet
Dim Source_Sheet As Worksheet
Dim FileUpdate As Worksheet

Set Template_Sheet = Sheets("Template")
Set Database_Sheet = Sheets("Database")
Set Source_Sheet = Sheets("Source")
Set FileUpdate = Sheets("NewFile")

Dim Database_Row_Count As Integer
Dim Database_Column_Count As Integer
Dim id_temp As String
Dim Row_Count As Integer
Dim Lat_Index As Integer

For i = 1 To FileUpdate.Rows.Count 'Count Rows
   If IsEmpty(FileUpdate.Cells(i, 1)) Then
        Row_Count = i - 1
        Exit For
    End If
Next i

Lat_Index = Source_Sheet.Cells(6, 1).Value
Database_Row_Count = Source_Sheet.Cells(6, 4).Value
Database_Column_Count = Source_Sheet.Cells(6, 5).Value

For i = 2 To (1 + Row_Count)
id_temp = Template_Sheet.Cells(i, 1).Value

Template_Sheet.Cells(i, 2).Value = Application.WorksheetFunction.VLookup(id_temp, Database_Sheet.Range(Database_Sheet.Cells(2, 1), Database_Sheet.Cells(Database_Row_Count, Database_Column_Count)), Lat_Index, False)

Next i

我知道,你猜对了,错误1004在运行。我已经将几乎所有这些值用于sub中的其他应用程序,因此我怀疑在调用VLookup函数时我的错误必须来自错误定义的参数。非常感谢帮助。

谢谢! d。

0 个答案:

没有答案