How to get url text out of field with HYPERLINK in it

后端 未结 4 1095
醉梦人生
醉梦人生 2021-01-11 20:29

I have a column with hyperlinks formula in it, for example:

=HYPERLINK(\"http://example.com\", \"Link\")

I want to get additional column, w

4条回答
  •  [愿得一人]
    2021-01-11 21:04

    You can use Google Apps Script and a combination of Macros, Menus, and Custom Functions to extract the value of the hyperlink out of the cell's formula.

    Here's how it would work:

    1. Open the Google Sheets document
    2. Go to Tools > Script Editor...
      A new browser window or tab will open
    3. Highlight and delete all of the code in Code.gs
    4. Replace everything in Code.gs with the contents from this Pastebin, taken from this Google Docs Help Forum topic
    5. Save the changes by going to File > Save
    6. Run this new script by clicking on Run > onOpen
    7. When prompted, authorize the script
    8. Go back to your Google Sheets document
      You'll see a new menu item has been created after Help, named "Extract"
    9. Select the cell(s), row(s) or column(s) in your spreadsheet that contain the =HYPERLINK functions
    10. Click on Extract -> Replace formulas with Text strings to initiate the script

    The macro will recursively extract out the URL of the hyperlink function, leaving you with just the value.

    Note: Always make a backup of your work before making any changes.

    I would recommend performing this task on a duplicate spreadsheet or at a minimum a copy of the original cells in case anything should go wrong of if you wish to retain the original cell's content or formatting.

提交回复
热议问题