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.
On this page
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 made | URL formula returned |
|---|---|---|
A2 | HYPERLINK with the address in quotes | https://www.irs.gov/forms-pubs/about-form-w-9 |
A5 | Inserted link from the Broken tab, rebuilt with HYPERLINK | https://www.opm.gov/policy-data-oversight/pay-leave/pay-administration/ |
A8 | Insert, then Link, on typed words | #N/A |
A9 | HYPERLINK 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.
=REGEXEXTRACT(FORMULATEXT(A2), "https?://[^""]+")Before C2 is =A2
| A | C | |
| 1 | Resource | URL |
| 2 | W-9 form | W-9 form |
| 3 | Shipping rates | Shipping rates |
| 4 | Weather | Weather |
| 5 | Pay calendar | Pay calendar |
What changed
C2:C5read the formula text of column AA5rebuilt with HYPERLINK
After Fixed tab
| A | C | |
| 1 | Resource | URL |
| 2 | W-9 form | https://www.irs.gov/forms-pubs/about-form-w-9 |
| 3 | Shipping rates | https://www.usps.com/ship/ |
| 4 | Weather | https://www.weather.gov/ |
| 5 | Pay calendar | https://www.opm.gov/policy-data-oversight/pay-leave/pay-administration/ |
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 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.

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.

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")".](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEil0KNWnda1A3zlMdlIEgl_RiGxZej4Jzt532DJwSqpw7ijje_wewBuqd2GUaF-Q50zNUcweFbA3AgFcGb4LvuQYmPkH48WMNT9VBw2KHM0jJQEhR2B0jZFKcSCJWwQiLmQPMpEkAV80YjeRzzaB80bEU2-lOiMaO2LFwbjmn2ERIh2VU7xuat59PWT9Al0/s1600/c9-na.png)
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 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.
| Input | Links in A2:A5 of the Fixed tab, all HYPERLINK formulas |
|---|---|
| Formula | =REGEXEXTRACT(FORMULATEXT(A2), "https?://[^""]+"), filled down to C5 |
| Expected | https://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 returned | https://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 |
| Checked | 2026-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.](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhvCBybbgDqMVELBLmuKBp4UoWAY34kJ00TPyMd6vl3cax2yJ9GkBraxBfP72W3F27uYzsngtMn2xXQBx1vncVp12Vs5-kxkC26g0eZwIq95vyIeF40xDJb-frpVAWW_EQvc495A-C3BhHzd6uu3AcLnXEry5DDRFWsbRS_k30M0SWinVEDDC30oTvwb_Bg/s1600/fixed.png)
Take-home copy. Four tabs: Broken (as you see it), Fixed, Try it yourself, Budget. It opens as a copy in your own Drive.