VBA Vlookup使用ActiveCell作为参考

时间:2018-05-22 16:23:49

标签: vba excel-vba excel

我有一个按钮,它会查看所选单元格的文本并引用不同表格中的表格以返回姓氏,名字。这就是我所拥有的:

Sub button1()
Dim name As String
Dim ArrayRange As Range
Dim ActCell As Range

Set ActCell = ActiveCell


Sheets("Results").Select
Set ArrayRange = Sheets("Results").Range("A1", Range("A1").End(xlToRight).End(xlDown))
Sheets(1).Select

Lastname = Application.WorksheetFunction.VLookup(ActCell.Value, ArrayRange, 13, False)
FirstName = Application.WorksheetFunction.VLookup(ActCell.Value, ArrayRange, 12, False)

MsgBox Lastname & FirstName
End Sub

我收到错误

  

无法获取WorksheetFunction类的vLookup属性

非常感谢任何帮助!

0 个答案:

没有答案