vba 无法获取 WorksheetFunction 类的 Vlookup 属性

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15503199/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 15:11:48  来源:igfitidea点击:

Unable to get the Vlookup property of the WorksheetFunction class

excelvbatypesvlookup

提问by Samantha Monti

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

我正在尝试从名为 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 CDateand CStrbut no use.

下面的代码出现错误消息“无法获取 WorksheetFunction 类的 Vlookup 属性”。我尝试将数据类型更改为CDateCStr但没有用。

concat = EmpName & GetDate

concat = EmpName & GetDate

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

Thanks in advance

提前致谢

回答by GTG

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

注意范围内的数据需要按升序排序,参见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.

table_array 第一列的值必须按升序排列;否则,VLOOKUP 可能不会给出正确的值。您可以通过从“数据”菜单中选择“排序”命令并选择“升序”将值按升序排列。有关更多信息,请参阅默认排序顺序。

回答by user3709758

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

Amy one 可以解决这个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:$C7"), 2, False)
Next K
Next J
Next I

End Sub

结束子