[英]Runtime error using VLookup with Excel
我不断得到:
运行时错误“ 1004”无法获取WorksheetFunction类的Vlookup属性
使用下面的Vlookup代码。
如果启用了Microsoft outlook 12.0 Object Library
则可以使用,但是我遇到了将代码与Excel 2013一起使用的问题,并添加了Excel 2007中不可用的Microsoft outlook 15.0 Object Library
引用。这部分代码除外。
我提供了一段代码,希望对某人有所帮助。
Sub Button154_Click()
Dim forename As String
Dim surname As String
Dim movedate As String
Dim callref As String
Dim dept As String
Dim deptmove As String
Dim wb As Workbook
Set wb = ThisWorkbook
forename = Sheet1.Range("f8").Value
surname = Sheet1.Range("f9").Value
movedate = Sheet1.Range("k13").Value
callref = Sheet1.Range("k8").Value
dept = Application.WorksheetFunction.VLookup(Name, Sheet1.Range("K10"), 1)
添加了后期绑定代码Dim otlApp作为对象集otlApp = CreateObject(“ Outlook.Application”)
将vlookup更改为:dept = Application.WorksheetFunction.VLookup(oltApp,Sheet1.Range(“ K10”),1)
现在效果很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.