HomeGoogle DocsSpreadsheetExtract URLs in Google Sheets without Script

Extract URLs in Google Sheets without Script

Published on

Without using Google Apps Script, you can extract URLs in Google Sheets.

It doesn’t matter whether the URL is linked to a label in a cell using the Hyperlink function, Insert menu “Insert link”, or copied from any website or blog page.

This method works even after the latest Google Sheets update that brought multiple Hyperlink feature. But using this method it’s not possible to extract multiple URLs from a single cell in Google Sheets.

The below screenshot (GIF) shows the URLs that we want to extract in the range A1:A. The extracted URLs are in C1:C. I have extracted the URLs without any App Scripts in Google Sheets!

Extract URLs in Google Sheets

In the above example, the cell A1 contains the link with the label copied from this blog.

In cell A2 and A3, I have hyperlinks. I mean I have used the Hyperlink function to link a label with URL.

So when you go to cell A1, you won’t see the URL on your Google Sheets formula bar. There is no formula to show. But on the other two cells, you will see the hyperlink formula.

If you use the menu Insert > Insert link to insert a hyperlink in cell A4, that link would behave just like the link in cell A1.

I mean you won’t see any formula in the formula bar (this started happening after the recent Hyperlink update).

From these three types of hyperlinks in cells, you can extract or separate the URLs in Google Sheets that without using any Apps Script.

How to extract the URLs in Google Sheets without any script or custom functions? Please follow the step-by-step instructions below.

How to Extract URLs in Google Sheets from Hyperlinks

Actually, there is no built-in function in Google Sheets that can extract URLs from a hyperlink in a cell.

There is one formula, but that will only work with the hyperlinks in cell A2 and A3, that is inserted via the Hyperlink function.

Here is that formula for your reference.

=REGEXEXTRACT(FORMULATEXT(A2),"""(.*)"",")

With the following workaround, that even novice Google Sheets users can follow, we can extract URLs from any type of (the said three above) hyperlinks. Here are the steps involved.

Step-By-Step Instructions to Separate URLs from Hyperlink

The above hyperlinks are in “Sheet1” (tab name) column A. I am going to extract the URLs in “Sheet2” (tab name).

Step 1: Copy Contents (Hyperlinks) to “Sheet2”

In “Sheet2” in cell A1 use the below formula to copy the contents (hyperlinks) available in “Sheet1” column A.

={Sheet1!A1:A}

If there are blank cells between the hyperlinks, then instead of the above simple formula, use the below Filter formula.

=filter(Sheet1!A1:A,Sheet1!A1:A<>"")

Step 2: Publish the Tab “Sheet1”

Go to the File menu and click on “Publish to the web” (later you can unpublish if you have confidential info in your sheet).

Under Link, select tab name, i.e. “Sheet1”, and then select “web page”.

publish Sheets to the web

Check “Automatically republish…” and click the “Publish” button.

Once published, you will get a link URL. Copy that.

Step 3: Import Published Google Sheets Contents Back to Google Sheets

In cell E1 in “Sheet2” enter the below formula (column E is my helper column).

=IMPORTXML("URL","//a/@href")

Replace the URL in this formula with the just copied (published) URL.

In cell C1 just enter the below SUBSTITUTE formula and voila!

=ArrayFormula(
     if(len(A1:A),
     SUBSTITUTE(
        mid(E1:E,1,search("&sa",E1:E)-1),
        "https://www.google.com/url?q=",
        ""
     ),
     )
)

Additional Notes

When you add more links to column A in “Sheet1” and want to extract that URLs too, unpublish the sheet, if already not. Then publish again to get the link.

Delete the existing IMPORTXML formula. Copy the formula under Step # 3 above (without URL) and again replace the text “URL” with the copied (published) URL.

How to Extract Link Labels in Google Sheets

You have successfully extracted the link URLs in Google Sheets, right? How to separate the link labels from hyperlink then?

We have the hyperlinks in Column A. In cell B1, apply the below ArrayFormula. This will extract the link labels.

separate hyperlink label in Google Sheets
=ArrayFormula(A1:A&"")

That’s all about extracting URLs from hyperlinks without Apps Script in Google Sheets.

Resources:

Prashanth KV
Prashanth KV
Your Trusted Google Sheets and Excel Guide Prashanth KV brings a wealth of experience in Google Sheets and Excel, cultivated through years of work with multinational corporations in Mumbai and Dubai. As a recognized Google Product Expert in Docs Editors, Prashanth shares his expertise through insightful blogging since 2012. Explore his blog for practical tips and guidance on maximizing your spreadsheet skills.

Counting XLOOKUP Results with COUNTIFS in Excel and Google Sheets

We can use COUNTIF or COUNTIFS alongside an XLOOKUP formula to conditionally count the...

Appointment Schedule Template in Google Sheets

An appointment schedule template in Google Sheets can assist you in efficiently managing your...

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Running Total By Month in Excel

This tutorial demonstrates how to calculate the running total by month in a range...

More like this

Appointment Schedule Template in Google Sheets

An appointment schedule template in Google Sheets can assist you in efficiently managing your...

Creating Sequential Dates in Equally Merged Cells in Google Sheets

Do you know how to create sequential dates in equally merged cells across a...

Interactive Random Task Assigner in Google Sheets

You have multiple tasks and multiple people. Here's a fun way to randomly assign...

15 COMMENTS

  1. Hi Prashanth,

    I was looking to get the ‘Sheet3’ url into a cell A1 with only formula (without script).

    Thank You.

  2. This worked, thank you!

    (Note: It does not work if you’re signed in to your company’s Gsuite account. Make sure to sign in to your personal Google account before starting the steps).

  3. Prashanth,

    So, I tried a couple of different things. The sheet I was trying to copy had around 1900 rows of URLs.

    Seems like the largest number of rows it will work with is around 1000

    To get it to work, I had to break it up into two sheets and just run the process twice.

    Pat

  4. Prashanth,

    I did everything as outlined above for Google Sheets. When I went to Step 3 it returned the following Error.

    “Resource at URL Contents Exceeded Maximum Size”

    Thoughts?

    Pat

    • Hi, Pat,

      Actually, I was unaware of that issue due to my testing with a limited dataset.

      Thanks for the info.

      You can try the following workaround.

      Remove unwanted rows and columns in your Sheet (published). The aim is to reduce the file size. Then try.

      If that doesn’t work, try to import a limited number of rows.

      Existing Formula.

      =IMPORTXML("URL","//a/@href")

      Play around with;

      =Array_Constrain(IMPORTXML("URL","//a/@href"),500,1)

      This formula imports 500 rows and 1 column.

      But I didn’t test any of the above workarounds.

      Thanks for your understanding.

      Best

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.