vba 带有 VLookup 的超链接 - 返回错误 - 无法打开指定文件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26075506/
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-12 04:40:48  来源:igfitidea点击:

Hyperlinks with VLookup - Returns Error - Cannot Open Specified File

excelexcel-vbaexcel-formulavba

提问by Jimmy Jim

The problem is:I have named ranges of cells in sheet3. In sheet2I have created hyperlinks using range names so once you click in any of the links it takes you direct to the related range in sheet3.

问题是:我在sheet3. 在sheet2我已经使用范围名称创建了超链接,因此一旦您单击任何链接,它就会将您直接带到sheet3.

In sheet1I have a table in which column Kis a droplist, in column LI entered this formula:

sheet1我有一个表,其中列K是下拉列表,在列中L我输入了这个公式:

=HYPERLINK(VLOOKUP(K3,Sheet2!B48:C92,2,0))

which return the hyperlink matching to the selected value in column Kthe result returned is exactly the hyperlink in the sheet2but whenever I click any of these hyperlink results an error message pop up saying: Cannot open the specified file.

它返回与列中选定值匹配的超链接,返回的K结果正是sheet2 中的超链接,但是每当我单击这些超链接中的任何一个结果时,都会弹出一条错误消息:无法打开指定的文件

Even all the links in Sheet2is working fine and it take me direct to the linked range in Sheet3.

即使所有的链接Sheet2工作正常,并把它我直接在链接的范围Sheet3

Do I need to insert a macro code to make the Vlookup-Hyperlinks results working and take me to the targeted range in Sheet3and whats the that code?

我是否需要插入宏代码才能使 Vlookup-Hyperlinks 结果正常工作并将我带到目标范围,Sheet3该代码是什么?

Thanks for your help.

谢谢你的帮助。

回答by Axel Richter

If =VLOOKUP(K3,Sheet2!B48:C92,2,0)returns the namewhich is the target range of the hyperlink which is working in Sheet2, then the following should work in a HYPERLINK function:

如果=VLOOKUP(K3,Sheet2!B48:C92,2,0)返回的名称是在 Sheet2 中工作的超链接的目标范围,那么以下应该在 HYPERLINK 函数中工作:

=HYPERLINK("#"&VLOOKUP(K3,Sheet2!B48:C92,2,0))

The correct syntax would be:

正确的语法是:

=HYPERLINK("[NameOfTheWorkbook]"&VLOOKUP(K3,Sheet2!B48:C92,2,0))

according to : http://office.microsoft.com/en-us/excel-help/hyperlink-function-HP010342583.aspx.

根据:http: //office.microsoft.com/en-us/excel-help/hyperlink-function-HP010342583.aspx

But the above syntax will also work. There the # works as a shortcut for "ThisWorkbook".

但上述语法也适用。在那里 # 用作“ThisWorkbook”的快捷方式。

Greetings

你好

Axel

阿克塞尔