问题描述
我正在尝试使用索引/匹配组合从定义的表“ tblPlant1”中引入一个值。问题出在Match函数的“错误2015”和Index函数的问题之间。我最终希望将匹配结果合并到索引函数中。我了解错误2015的
Dim plantcode As String
Dim tblPlant1 As ListObject
Dim matchresult As Variant
Dim errormsg As String
Dim VIN As String
Dim Plant1 As Variant
Set tblPlant1 = ThisWorkbook.Sheets(1).ListObjects("tblPlant1")
VIN = ActiveCell.Value
plantcode = Mid(VIN,11,1)
errormsg = "Error: Plant Code " & Chr(34) & plantcode & Chr(34) & " (VIN Digit 11) Not Found"
matchresult = Application.Match(plantcode,tblPlant1.ListColumns("VIN"),0)
Plant1 = WorksheetFunction.IfError(Application.Index(tblPlant1.ListColumns("Plant"),6),errormsg)
Debug.Print errormsg
Debug.Print VIN
Debug.Print plantcode
Debug.Print matchresult
Debug.Print Plant1
调试的输出如下:
1HTKSSWK9KH067162
H
错误2015
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)