Automatically Extract Hyperlink URLs from Excel Column A with VBA
Question details
Automatically copy the URL behind hyperlinks in Excel column A to the adjacent column whenever the source cells are changed.

- Product
- Microsoft Excel VBA
- Device & OS
- not provided
- Scenario
- The user wants a worksheet-level automation that extracts hyperlink addresses from column A into column B for existing and newly edited cells.
- Observed behavior
- A regular worksheet formula does not automatically populate URL values for hyperlinks added to new rows later.
Save the workbook as an Excel Macro-Enabled Workbook (*.xlsm) before adding VBA code. Open the Visual Basic Editor with Alt+F11 and make sure you add the event procedure to the specific worksheet module, not to a standard module.
Use a Worksheet_Change macro to copy hyperlink URLs to column B
Use this option when URLs should be extracted automatically after cells in column A are edited or pasted.
This worksheet event checks changed cells in column A. If a cell has a hyperlink, its first hyperlink address is written to the corresponding cell in column B; otherwise, the cell in column B is cleared.
In Excel, press Alt+F11 to open the Visual Basic Editor. In the Project Explorer, expand your workbook, expand Microsoft Excel Objects, and double-click the worksheet that contains the hyperlinks.
Paste the following code into that worksheet code window: Private Sub Worksheet_Change(ByVal Target As Range) Dim cell As Range If Intersect(Target, Me.Columns("A")) Is Nothing Then Exit Sub For Each cell In Intersect(Target, Me.Columns("A")) If cell.Hyperlinks.Count > 0 Then cell.Offset(0, 1).Value = cell.Hyperlinks(1).Address Else cell.Offset(0, 1).ClearContents End If Next cell End Sub
Choose File > Save As and select Excel Macro-Enabled Workbook (*.xlsm). When reopening the file, select Enable Content in Excel's security warning.
Add, paste, or edit a hyperlink in column A, then check the matching row in column B. The macro writes the hyperlink URL to column B when the worksheet change event runs.

Run a macro to scan all existing hyperlinks in column A
Use this option when existing hyperlinks need to be extracted in bulk or when hyperlink dialog actions do not trigger Worksheet_Change.
Extract Hyperlink URLs with WPS Spreadsheet Macros
WPS Spreadsheet provides a familiar worksheet environment for organizing hyperlink lists and automating repetitive URL extraction. Open a macro-enabled workbook, use the macro editor to add compatible automation code, and keep the hyperlink address results in an adjacent column.
- 1. Open the workbook in WPS Spreadsheet: Launch WPS Office and open the Excel workbook containing hyperlinks in column A.
- 2. Access macro tools: Use the Developer or Macro tools in WPS Spreadsheet to open the macro editor for the workbook.
- 3. Add the hyperlink extraction routine: Insert the worksheet event code or a scan macro, then set column B as the output column for extracted addresses.
- 4. Save as a macro-enabled workbook: Use File > Save As and choose a macro-enabled workbook format when available so the automation remains with the file.

Frequently Asked Questions
Where should I paste the Worksheet_Change code in Excel?
Paste it into the code module for the specific worksheet that contains the hyperlinks. In the Visual Basic Editor, under Microsoft Excel Objects, double-click that worksheet and paste the procedure there.
Why does the hyperlink URL not appear in column B after I insert a link?
Some links added through Excel's Insert Hyperlink dialog do not trigger Worksheet_Change. Run a separate scan macro for column A, or use the HYPERLINK function when creating the link.
Can the macro extract URLs from multiple changed cells at once?
Yes. The For Each cell loop processes every changed cell within column A, including a range of cells pasted into the column.
Does this macro work with display text that is different from the URL?
Yes. The code reads cell.Hyperlinks(1).Address, which is the hyperlink destination rather than the visible display text.
Why must the workbook be saved as an XLSM file?
The .xlsx format cannot retain VBA code. Save the workbook as Excel Macro-Enabled Workbook (*.xlsm) and enable macros when opening it.




