简体   繁体   中英

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. 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".

You can achieve this by using Google scripts. (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 . Get those values and set the value of cell C8 to a hyperlink with the values derived from A8 and B8.

No need for Apps Script!

You can simply use the HYPERLINK formula like this:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM