vba 根据单元格中的特定文本超链接到另一个工作表
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17618956/
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
Hyperlink to another sheet based on specific text in cell
提问by user2577032
I'm working on a project involving pricing information for various retailing stores. On the main page, the user can enter in a store in cell G6. There will be a sheet with the exact same name as the user's cell entry. For example:
我正在从事一个涉及各种零售商店定价信息的项目。在主页面上,用户可以在单元格 G6 中进入商店。将有一个与用户的单元格条目同名的工作表。例如:
User enters "Wal-Mart" -- Sheet named "Wal-Mart" User enters "Target" -- Sheet named "Target"
用户输入“沃尔玛”——名为“沃尔玛”的工作表 用户输入“目标”——名为“目标”的工作表
My question is, how can I have the cell automatically hyperlink to the sheet of the same text value? I would prefer a formula over VBA, but any help is appreciated.
我的问题是,如何让单元格自动超链接到具有相同文本值的工作表?我更喜欢 VBA 的公式,但感谢任何帮助。
Thank you! - DJ
谢谢!- DJ
回答by SeanC
Without using VBA to detect the change, and update the hyperlink, you could not affect the same cell
如果不使用 VBA 检测更改并更新超链接,则无法影响同一个单元格
You can, however, use another cell that would have the appropriate hyperlink. You do have to know the name of the workbook, as the hyperlink requires the workbook name (i.e. just "Target!A1" would not work)
但是,您可以使用具有适当超链接的另一个单元格。您必须知道工作簿的名称,因为超链接需要工作簿名称(即仅“Target!A1”不起作用)
=HYPERLINK("[MyWorkbook.xlsx]" & G6 & "!A1","Goto Sheet")
This will create a link in the cell you put this formula in, which would then go to A1 of the sheet name typed in.
这将在您放置此公式的单元格中创建一个链接,然后将转到输入的工作表名称的 A1。
Example View:
Clicking the Goto Sheetwill go to the cell referenced in the formula (in this case, [MyWorkbook.xlsx]Sheet2!A1)
示例视图:
单击Goto Sheet将转到公式中引用的单元格(在本例中为[MyWorkbook.xlsx]Sheet2!A1)