如何在Excel VLookup公式中使用命名范围 [英] How to use Named Range in Excel VLookup Formula

查看:151
本文介绍了如何在Excel VLookup公式中使用命名范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Forum,

我正在使用visual studio 2015社区版进行XL自动化,

I am doing XL automation using visual studio 2015 community version,

我正在奋斗超过一天,以获得以下问题的解决方案。

I am struggling more than a day, to get the solution for the below problem.

Dim lookup_value As String = Msht.Range("B" & Mshtlr + 1).Value

xlapp.ActiveWorkbook.Names.Add(Name:="LookupRange", RefersToR1C1:="=" & CkSht.Name & "!R1C1:R" & CommonExcelFunctions.lastrow(CkSht,, "E") & "C5")
            Msht.Activate()

            xlapp.Range("C" & Mshtlr + 1).Value = xlapp.WorksheetFunction.VLookup(lookup_value, xlapp.Range("LookupRange"), 4, False)




我不断收到以下错误

An mscorlib.dll中发生未处理的"System.Runtime.InteropServices.COMException"类型异常



其他信息:WorksheetFunction类的VLookup方法失败

" lookup_value"设置正确。

"lookup_value" is set correctly.

" LookupRange"也可以在预期的工作表中正确设置。

"LookupRange" is also set correctly in the expected sheet.

对上述问题的任何回复表示赞赏。

Any reply on the above question is appreciated.

我无法使用"WorksheetFunction"。间接"

I am not able to use "WorksheetFunction.Indirect"

提前致谢

Thanks in Advance

Thiyagarajan

Thiyagarajan

推荐答案

因为问题是使用VLookup()方法调用,您可以从Excel for Developers论坛获得更好的支持。 我将此线程移至该论坛,如果他们发现问题不在于VLookup
方法调用或其参数值,则另一位主持人可以将其移回。
Since the problem is with the VLookup() method call, you may get better support from the Excel for Developers forum.  I will move this thread to that forum and another moderator can move it back if they find that the problem does not lie in the VLookup method call or its parameter values.


这篇关于如何在Excel VLookup公式中使用命名范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆