All posts
TutorialApril 22, 20264 min read

How to extract hyperlinks from Excel and Google Sheets

Excel hides hyperlinks behind display text — getting the actual URL out takes a HYPERLINK trick or a tiny VBA function. Google Sheets has its own quirks. Here's the full set.

By Dawid Sibinski

An Excel cell can show "Click here" while linking to https://example.com/long-url. There's no built-in formula in classic Excel that returns the URL behind a hyperlink — you have to dig for it.

Excel 365: HYPERLINK function works one direction only

=HYPERLINK("https://example.com", "Click here") creates a hyperlink. There's no inverse function that reads the URL back from an existing cell. This is the most common surprise.

Excel: tiny VBA function (most reliable)

Open the VBA editor (Alt+F11), Insert → Module, paste:

Function GetURL(c As Range) As String On Error Resume Next GetURL = c.Hyperlinks(1).Address End Function

Save the workbook as .xlsm, then use =GetURL(A1) anywhere in the sheet. Returns the underlying URL or empty if the cell isn't a hyperlink.

Excel: no-VBA workaround

If macros aren't allowed: select the column with hyperlinks, copy, paste into an empty Word document, then copy from Word back to Excel. Word converts hyperlinked text into the visible URL form. Awkward but it works in locked-down environments.

Excel: hyperlinks added via Insert → Hyperlink vs. typed URLs

If users typed the URL directly and Excel auto-linked it, the visible text already is the URL — no extraction needed. The VBA function above handles both cases. The "hidden URL" problem only arises when someone used Insert → Hyperlink (or imported from a source that did).

Google Sheets: built-in friendlier

Sheets doesn't have an inverse HYPERLINK either, but the workaround is cleaner via Apps Script:

function GETURL(input) { const range = SpreadsheetApp.getActiveSheet().getRange(input); return range.getRichTextValue().getLinkUrl(); }

Then =GETURL("A1") returns the URL behind the hyperlink in A1. Note: input must be quoted as a string (the cell reference, not the value) — Apps Script doesn't get the cell reference natively.

Bulk: dump the .xlsx as XML

An .xlsx file is a ZIP archive. Inside, xl/worksheets/sheet1.xml lists every hyperlink with its target. Useful when you have hundreds of cells and want them all in one shot:

unzip -p workbook.xlsx 'xl/worksheets/sheet1.xml' | grep -oE 'r:id="[^"]+"|display="[^"]+"'

For a cleaner programmatic version, openpyxl's Worksheet.cell(row, col).hyperlink.target gives you the URL directly.

More on tutorial

Stop reading, start extracting

Drop a PDF or image into ExtractFox and get structured data back in seconds.

Try a free extraction →