我正在尝试执行自动vlookup功能,但是我遇到了运行时错误:
1004 "Unable to get the Vlookup property of the worksheet functionclass"
需要一些帮助,说明它可能出错的地方以及如何调整它!
这是代码:
Sub FINDSAL()
'On Error GoTo MyErrorHandler:
Dim Seat_No As String
Seat_No = InputBox("Enter the Seat Number:")
If Len(Seat_No) > 0 Then
nameit = Application.WorksheetFunction.Vlookup(Seat_No, Sheets("L12 - Data Sheet").Range("B4:E250"), 2, False)
MsgBox "The name is : $ " & nameit
Else
MsgBox ("You entered an invalid value")
End If
Exit Sub
MyErrorHandler:
If Err.Number = 1004 Then
MsgBox "Employee Not Present in the table."
End If
End Sub
答案 0 :(得分:0)
Sub FINDSAL()
On Error GoTo MyErrorHandler:
Dim Seat_No As Integer
Seat_No = InputBox("Enter the Seat Number:")
If Len(Seat_No) > 0 Then
nameit = Application.WorksheetFunction.Vlookup(Seat_No, Sheets("L12 - Data Sheet").Range("B4:E250"), 2, False)
MsgBox "The name is : $ " & nameit
Else
MsgBox ("You entered an invalid value")
End If
Exit Sub
MyErrorHandler:
If Err.Number = 1004 Then
MsgBox "Employee Not Present in the table."
End If
End Sub