Sheet Clinic

Extract URL from hyperlink in Google Sheets, and link to a tab

=A2 copies a link's label, not its address. REGEXEXTRACT on FORMULATEXT extracts the URL from a HYPERLINK, and #gid links jump to a tab.

Sheet Clinic editorsPublished

To extract the URL from a hyperlink in Google Sheets, read the link's formula text instead of the cell. For a link in A2, =REGEXEXTRACT(FORMULATEXT(A2), "https?://[^""]+") returns the web address, filled down one row at a time. FORMULATEXT returns the HYPERLINK formula as text, and REGEXEXTRACT picks the address out of it. That only works when the link is a HYPERLINK formula with the address in quotes. A link added with Insert, then Link has no formula to read and has to be rebuilt as a HYPERLINK first.

A plain reference doesn't do it. The URL column of a four-row resource list should hold four web addresses. Cell C2 holds =A2 and shows W-9 form, the words of the link in A2. The next three rows give back Shipping rates, Weather and Pay calendar. On the Broken tab the labels in C2:C5 even come out blue and underlined, so the column looks finished until you read it.

The table below runs that URL formula against four links on the Fixed tab. A2 and A5 are both HYPERLINK formulas with the address in quotes; A5 is the Broken tab's inserted link after we rebuilt it.

Link cell (Fixed tab)How the link was madeURL formula returned
A2HYPERLINK with the address in quoteshttps://www.irs.gov/forms-pubs/about-form-w-9
A5Inserted link from the Broken tab, rebuilt with HYPERLINKhttps://www.opm.gov/policy-data-oversight/pay-leave/pay-administration/
A8Insert, then Link, on typed words#N/A
A9HYPERLINK pointing at the address in B9#N/A

A8 is the inserted kind, with no formula behind it. A9 misses for a simpler reason: a HYPERLINK that points at another cell already has its address sitting in that cell.

A link that jumps to another tab is a HYPERLINK formula too. On the Fixed tab, =HYPERLINK("#gid=1798547534&range=B8", "Budget total") opens the Budget tab with B8 selected, and the number after gid is read from the browser address while that tab is open.

Extracting the URL with REGEXEXTRACT and FORMULATEXT

Type this in C2, then fill it down to C5. From sheet to sheet the only part that changes is A2, the cell that holds the link:

=REGEXEXTRACT(FORMULATEXT(A2), "https?://[^""]+")

According to Google's page, FORMULATEXT returns what is displayed in the formula bar when the cell is selected. For the W-9 row that is the whole string =HYPERLINK("https://www.irs.gov/forms-pubs/about-form-w-9", "W-9 form"). REGEXEXTRACT then looks for http, an optional s, the two slashes, and every character after them up to the next double quote. Inside a formula a double quote in a string has to be typed twice, which is why the pattern shows "" between the brackets. If the cell shows #ERROR! once the formula is in, curly quotes and a missing quote are two of the slips covered in the post on Formula parse error.

C2=REGEXEXTRACT(FORMULATEXT(A2), "https?://[^""]+")

Before C2 is =A2

AC
1ResourceURL
2W-9 formW-9 form
3Shipping ratesShipping rates
4WeatherWeather
5Pay calendarPay calendar

What changed

  1. C2:C5 read the formula text of column A
  2. A5 rebuilt with HYPERLINK

After Fixed tab

AC
1ResourceURL
2W-9 formhttps://www.irs.gov/forms-pubs/about-form-w-9
3Shipping rateshttps://www.usps.com/ship/
4Weatherhttps://www.weather.gov/
5Pay calendarhttps://www.opm.gov/policy-data-oversight/pay-leave/pay-administration/
Figure 1. The same four links. On the left, column C repeats the labels. On the right, it holds the addresses.

On the Fixed tab, C2 returned https://www.irs.gov/forms-pubs/about-form-w-9, C3 returned https://www.usps.com/ship/, C4 returned https://www.weather.gov/ and C5 returned the long pay page address on opm.gov. Each one matches the address typed into the HYPERLINK formula in column A.

Fill it down row by row instead of handing FORMULATEXT the range A2:A5 inside ARRAYFORMULA. The FORMULATEXT page says that when a range is passed in, only the top-left cell is evaluated.

Why a reference to a link cell returns only its label

A link made with HYPERLINK has two parts, and only one of them is the value of the cell. Google's page for the HYPERLINK function calls them url and link_label. The label is what the cell displays, and it is also what every other formula receives. Select C2 on the Broken tab and the formula bar shows =A2 while the cell shows W-9 form. The words are all that came across, with no address anywhere in them.

The Broken tab with C2 selected. The formula bar shows =A2. Column A and column C both show the underlined labels W-9 form, Shipping rates, Weather and Pay calendar. E2 and E3 show the plain words Budget and Budget total.
Figure 2. The Broken tab. Column C repeats the labels from column A.

The address is still in the sheet. For A2, A3 and A4 it sits inside the formula text, where FORMULATEXT can read it. A5 holds no formula at all.

A link added from the Insert menu has no formula to read

On the Broken tab, A5 looks like the three links above it. It was made another way: the words Pay calendar were typed in, and the link was added with Insert, then Link (⌘K on a Mac, Ctrl+K on Windows), the route described on Google's links help page. Select A5 and the formula bar shows only Pay calendar.

The Fixed tab keeps a second link made the same way in A8, so the result stays visible. =ISFORMULA(A8) returned FALSE. The URL formula in C8 returned #N/A, and selecting C8 brings up the note Invalid formula parse result. On the Broken tab, =A5 in C5 gave the label, and FORMULATEXT had no formula to hand over.

The Fixed tab with C8 selected. C8 shows #N/A and an Error note reads: Invalid formula parse result.
Figure 3. C8 on the Fixed tab, where the URL formula reads the inserted link in A8: #N/A, with the note Invalid formula parse result.

You can still read the address by hand. Clicking A5 opens a card under the cell with the page title, Pay Administration, and the start of the address. That worked in a signed-out window where the sheet was view only. The card cuts long addresses short, and this one was cut after opm.gov/policy-data-oversight/pay-le.

The Broken tab with A5 selected. A card under the cell shows the title Pay Administration and the text opm.gov/policy-data-oversight/pay-le followed by an ellipsis.
Figure 4. The link card for A5. It shows the page title and a shortened address.

For a column you want to keep working with formulas, rebuild the cell as a HYPERLINK. Open the link, copy the address from the browser, and type it into a formula with the old words as the label. That is what A5 on the Fixed tab is now: =HYPERLINK("https://www.opm.gov/policy-data-oversight/pay-leave/pay-administration/", "Pay calendar"). With a formula in place, C5 returned the full address.

When HYPERLINK points at another cell, the URL is in that cell

Row 9 of the Fixed tab is a link that does have a formula, and the URL formula still fails. A9 is =HYPERLINK(B9, "Benefits"), with the address typed into B9. =ISFORMULA(A9) returned TRUE, so a formula is there. The trouble is what FORMULATEXT reads: the text =HYPERLINK(B9, "Benefits"), which has no http in it. C9 shows #N/A and this note:

Function REGEXEXTRACT parameter 2 value "https?://[^"]+" does not match text of Function REGEXEXTRACT parameter 1 value "=HYPERLINK(B9, "Benefits")".

Here the address was never inside the formula. It is in B9, and =B9 returns https://www.opm.gov/healthcare-insurance/. When a list mixes the two styles, select a cell that failed and look at the formula bar. An address in quotes means the pattern will find it. A cell reference means the address lives in that cell, and you can point at it directly.

The Fixed tab with C9 selected. C9 shows #N/A and an Error note reads: Function REGEXEXTRACT parameter 2 value "https?://[^"]+" does not match text of Function REGEXEXTRACT parameter 1 value "=HYPERLINK(B9, "Benefits")".
Figure 5. The note quotes the formula text it searched, and there is no address in it.

Linking to another tab or cell with HYPERLINK, #gid and range

The second half of the Broken tab is a short index. E1 says Jump to, and below it E2 and E3 hold the words Budget and Budget total. Nothing happens when you click them. On the Fixed tab they are links:

  • =HYPERLINK("#gid=1798547534", "Budget") goes to the Budget tab.
  • =HYPERLINK("#gid=1798547534&range=B8", "Budget total") goes to the total in B8 of that tab.

The number after gid is the tab's ID inside this spreadsheet. With the Budget tab open, the browser address ends in #gid=1798547534, which is where we copied it from.

The gid in E2 and E3 is the number we read for the Budget tab in this file. If you build the same index in a different spreadsheet, open the target tab there and copy the number after gid from that address bar, then put the cell the link should land on after range=.

We tested E3 in a signed-out window, where the sheet opens as view only. Clicking E3 opened a card that reads Budget!B8. Clicking that card switched to the Budget tab in the same browser tab, with B8 selected. The formula bar showed =SUM(B2:B7), and the cell showed 2430.

The Fixed tab with E3 selected. The formula bar shows =HYPERLINK("#gid=1798547534&range=B8", "Budget total") and a card next to the cell reads Budget!B8.
Figure 6. The card names the tab and cell the link goes to.
The Budget tab after following the link. B8 is selected, the formula bar shows =SUM(B2:B7) and B8 shows 2430.
Figure 7. Where the E3 link landed: B8 on the Budget tab.

The links help page also describes a menu route to the same place: Insert, then Link, then the option to select a range of cells. We did not use the menu route in this sheet. E2 and E3 here are formulas, so the tab number and the cell address stay in plain sight in the formula bar.

Rebuilding the URL column and the tab links on the Try it yourself tab

For practice, the Try it yourself tab has the labels in column C and plain words in E2 and E3, the way the Broken tab does. Type the REGEXEXTRACT formula into C2, C3 and C4, changing A2 to A3 and A4 as you go. Then type the two HYPERLINK formulas over the words in E2 and E3, and compare C2:E4 with the same block on the Fixed tab.

Leave C5 for last. A5 on the Try it yourself tab is still the inserted link, so the formula there returns #N/A until you rebuild A5 with HYPERLINK the way the Fixed tab does.

InputLinks in A2:A5 of the Fixed tab, all HYPERLINK formulas
Formula=REGEXEXTRACT(FORMULATEXT(A2), "https?://[^""]+"), filled down to C5
Expectedhttps://www.irs.gov/forms-pubs/about-form-w-9, https://www.usps.com/ship/, https://www.weather.gov/, https://www.opm.gov/policy-data-oversight/pay-leave/pay-administration/
Sheets returnedhttps://www.irs.gov/forms-pubs/about-form-w-9, https://www.usps.com/ship/, https://www.weather.gov/, https://www.opm.gov/policy-data-oversight/pay-leave/pay-administration/ Matches expected
Checked2026-11-11, free personal account
The Fixed tab with C2 selected. The formula bar shows =REGEXEXTRACT(FORMULATEXT(A2), "https?://[^""]+"). C2:C5 show four web addresses, E2 and E3 show the links Budget and Budget total, and C8 and C9 show #N/A.
Figure 8. The Fixed tab. Column C holds the addresses. Rows 8 and 9 are the two kinds of link this formula cannot read.

Take-home copy. Four tabs: Broken (as you see it), Fixed, Try it yourself, Budget. It opens as a copy in your own Drive.

Copy the sheet