[英]In Google Sheets - creating a link in one cell that combines information from two cells?
In Google sheets, I am trying to populate one cell with a link that is created from two different cells.在 Google 表格中,我试图用从两个不同单元格创建的链接填充一个单元格。 So, for example: A1 contains the text "Google", A2 contains the link "www.google.com", I would like for A3 to automatically contain the text "Google" while being hyperlinked to "www.google.com".
因此,例如:A1 包含文本“Google”,A2 包含链接“www.google.com”,我希望 A3 自动包含文本“Google”,同时超链接到“www.google.com”。
You can achieve this by using Google scripts.您可以使用 Google 脚本来实现这一点。 (Click on Menu | Tools | Script Editor).
(单击菜单 | 工具 | 脚本编辑器)。
Also, to run this example, set the value of the following:此外,要运行此示例,请设置以下值:
Cell A8: Google
Cell B8: https://www.google.com
Sample Code:示例代码:
function createHyperLink () {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var sheet = ss.getSheets()[0];
var cellContainingText = sheet.getRange("A8:A8");
var cellContainingLink = sheet.getRange("B8:B8");
var textWithLink = '=HYPERLINK("' + cellContainingLink.getValue() + '", "'+ cellContainingText.getValue() + '")';
var cellToModify = sheet.getRange("C8:C8");
cellToModify.setValue(textWithLink);
}
Assume that your text value is in cell A8
and your corresponding hyperlink is in cell B8
.假设您的文本值在单元格
A8
中,并且相应的超链接在单元格B8
中。 Get those values and set the value of cell C8
to a hyperlink with the values derived from A8 and B8.获取这些值并将单元格
C8
的值设置为具有从 A8 和 B8 派生的值的超链接。
No need for Apps Script!无需 Apps 脚本!
You can simply use the HYPERLINK formula like this:您可以像这样简单地使用 HYPERLINK 公式:
=HYPERLINK(B1,A1)
=HYPERLINK(B1,A1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.