简体   繁体   English

在 Google 表格中 - 在一个单元格中创建一个链接来组合来自两个单元格的信息?

[英]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 公式:

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google Sheets GROUPBY 将值组合到一个单元格中以满足分组列的查询 - Google Sheets GROUPBY Query that combines values into one cell to satisfy grouped columns 谷歌表格,两种字体大小一个单元格 - Google Sheets, Two Font Sizes One Cell 什么公式可以在 Google 表格中用于将数据从一个单元格拆分和提取到多个单元格? - What formula will work in Google Sheets to split and extract data from one cell to multiple cells? 搜索匹配的单元格,然后将一个单元格复制到 Google 表格中的其他位置 - Search for matching cells then copy one cell to a different location in Google Sheets Google表格可以将一个单元格更改为另一个单元格 - Google Sheets change one cell from another 需要将Google表格中的单元格与其他单元格中的值合并 - Need to merge cells in Google Sheets from value in another cell 在 Google 表格中获取指向此单元格的链接 - Get Link to this cell in Google sheets 通过第三方链接将数据写入 Google 表格中的单元格 - Writing data to a cell in Google Sheets from a 3rd party link 谷歌表格寻找像 VLOOKUP 这样的谷歌脚本,但结合了找到的值并将它们连接到一个特定的单元格中 - Google Sheets looking for a google script like VLOOKUP but combines the found values and joins them into a specific cell 使用脚本Google表格将数据从一个单元格范围移动到另一个单元格 - Moving data from one range of cells to another with a script Google Sheets
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM