VBA & Macro Problems

How to Extract a Hyperlink URL from an Excel Cell with VBA in WPS Office

Emma BrownEmma Brown Nov 13, 2026 869 views

Question details

The user needs to extract the actual URL stored in a hyperlink cell into another column using a VBA function because no standard worksheet formula reliably reads the hyperlink object address.

How to Extract a Hyperlink URL from an Excel Cell with VBA in WPS Office
Product
WPS Office Spreadsheets
Device & OS
not provided
Scenario
A worksheet contains display text linked to web addresses, and the user wants to copy the underlying hyperlink URLs into a separate column for reporting or cleanup.
Observed behavior
WPS Spreadsheets/Excel does not provide a standard worksheet formula that directly returns the hyperlink object's address, so a custom VBA routine is required.
Before you start

Make sure your workbook is saved as a macro-enabled .xlsm file and that macros are allowed in WPS Spreadsheets. Open the workbook in WPS Office and enable the Developer tab if you prefer to access the Visual Basic Editor from the ribbon.

Solution 1Recommended

Create a GetURL VBA function to read a hyperlink address

Use this solution when you need a reusable worksheet function that returns the hidden URL from any hyperlinked cell.

This approach adds a custom function named GetURL. It checks the cell's Hyperlinks collection and returns the Address property when a hyperlink exists; otherwise it returns an empty string.

1
Open the Visual Basic Editor

In WPS Spreadsheets, press Alt+F11 to open the Visual Basic for Applications editor.

2
Insert a standard module

In the VBA editor, click Insert > Module to create a new standard module.

3
Paste the VBA function

In the new module, paste the following function: Function GetURL(cell As Range) As String If cell.Hyperlinks.Count > 0 Then GetURL = cell.Hyperlinks(1).Address Else GetURL = "" End If End Function

4
Use the function in a worksheet

Return to WPS Spreadsheets, select the cell where you want the extracted URL, and enter =GetURL(A1), replacing A1 with the hyperlinked cell reference.

5
Save and enable macros

Save the workbook as an Excel Macro-Enabled Workbook (.xlsm). When you reopen the file, click Enable Content or enable macros if prompted.

Create a GetURL VBA function to read a hyperlink address
Macro-enabled workbook required: Always save the file as .xlsm and enable macros, otherwise the custom VBA function will not run or will display a #NAME? error.
WPS Spreadsheets VBA Macro

Extract Hyperlink URLs in WPS Office with a Custom VBA Function

WPS Office Spreadsheets can handle this task directly with a small VBA function. You can create the GetURL function once, use it like a normal worksheet formula, and keep your workbook fully compatible with Microsoft Excel .xlsm macro-enabled files.

  1. 1. Open WPS Spreadsheets: Launch WPS Office and open the workbook that contains the hyperlinked cells.
  2. 2. Access the VBA editor: Press Alt+F11 or go to Developer > Visual Basic to open the VBA editor.
  3. 3. Add the GetURL function: Insert a standard module and paste the GetURL VBA function, then close the editor.
  4. 4. Extract URLs with a formula: In the target column, enter =GetURL(A1) and fill down to return each hyperlink address.
Extracts hidden hyperlink addresses without manual copy-pasteUses the familiar VBA Hyperlinks property supported in WPS SpreadsheetsPreserves Microsoft Excel .xlsm format compatibilityReusable formula works across the entire worksheet column
microsoft office alternative - wps office

Frequently Asked Questions

Why does =GetURL(A1) return a blank value even though the cell is a hyperlink?

A blank result means the function did not find a hyperlink object in the referenced cell. Check that A1 contains an inserted hyperlink, not only blue underlined text, and that the cell reference in the formula points to the correct cell.

Can I use the GetURL function to extract URLs for an entire column?

Yes. Enter =GetURL(A1) in the first cell of the target column, then use the fill handle to copy it down. The cell reference updates automatically, so =GetURL(A2) reads A2, and so on.

Do I need to save my WPS Spreadsheets workbook in a special format to keep the VBA function?

Yes. Save the workbook as an .xlsm macro-enabled workbook. If you save it as a normal .xlsx file, WPS Spreadsheets may prompt you that the VBA project cannot be kept in the file format.

Will this VBA function work when the workbook is opened in Microsoft Excel?

Yes. The GetURL function uses standard Hyperlinks and Address properties, so the .xlsm workbook can be opened in Microsoft Excel with macro support enabled and the formula will generally work normally.