Unable to get the Vlookup property of the WorksheetFunction class

僤鯓⒐⒋嵵緔 提交于 2019-12-23 22:16:35

问题


I am trying to find an Employee name and their Import date from a spreadsheet called CashReward.

The coding below is appearing with an error message 'Unable to get the Vlookup property of the WorksheetFunction class'. I have tried changing the data type to CDate and CStr but no use.

concat = EmpName & GetDate

BasicSal = WorksheetFunction.VLookup(CVar(concat), Sheets("CashReward").Range("G3:K" & Cashlastrow), 2, False)

Thanks in advance


回答1:


This happens if your search string is not found in the given range.

Note that the data in the range needs to be sorted in ascending order, see http://office.microsoft.com/en-us/excel-help/vlookup-HP005209335.aspx

The values in the first column of table_array must be placed in ascending sort order; otherwise, VLOOKUP may not give the correct value. You can put the values in ascending order by choosing the Sort command from the Data menu and selecting Ascending. For more information, see Default sort orders.




回答2:


Amy one can solve this erroe run time error '424' object require

Private Sub VLOOKUP()
Dim I As Integer
Dim J As Integer
Dim K As Integer

For I = 2 To 14

For J = 1 To 1
For K = 2 To 2


Sheet2.Cells(I, K) = Appliaction.WorksheetFunction.VLOOKUP(Sheet2.Cells(I, J), Sheet1.Range("$A$1:$C$307"), 2, False)
Next K
Next J
Next I

End Sub



来源:https://stackoverflow.com/questions/15503199/unable-to-get-the-vlookup-property-of-the-worksheetfunction-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!