VBA & Macro Problems

How to Find Duplicate Hyperlinks Using Excel Conditional Formatting & VBA

Tauseeq MagsiTauseeq Magsi Oct 26, 2026 868 views

Question details

Identify and highlight duplicate hyperlink addresses in a spreadsheet, even when their display texts are different.

How to Find Duplicate Hyperlinks in Excel with Conditional Formatting
Product
Excel
Device & OS
not provided
Scenario
Managing a spreadsheet with multiple links where standard conditional formatting fails because it only compares display text, not the underlying URL.
Observed behavior
Standard conditional formatting ignores the actual hyperlink address and only checks visible text, making it impossible to find duplicate URLs using native formatting alone.
Before you start

Ensure that your workbook is saved as a Macro-Enabled Workbook (.xlsm), as you will need to use a VBA script to extract the underlying hyperlink addresses before applying conditional formatting.

Solution 1Recommended

Extract and Highlight Duplicate Hyperlinks Using a VBA Helper Function

Create a custom VBA function to extract the actual URL from the hyperlink, then use conditional formatting to highlight duplicates based on the extracted URLs.

Since Excel's native conditional formatting cannot read the hidden URL of a hyperlink, we must first extract the URL into a helper column. A short VBA script makes this extraction automatic.

1
Open the VBA Editor

Press Alt + F11 on your keyboard to open the Visual Basic for Applications (VBA) editor. Go to Insert > Module in the top menu to create a new module.

2
Insert the Custom Function

Copy and paste the following code into the blank module window: Function ShowHyperlink(ByVal Where As Range) As String ShowHyperlink = Where.Hyperlinks(1).Address End Function. Close the VBA editor when done.

3
Extract the URLs

In an empty column adjacent to your hyperlinks, type the formula =ShowHyperlink(A2) (assuming your first hyperlink is in cell A2). Press Enter, then drag the fill handle down to extract all URLs in your list.

4
Apply Conditional Formatting

Select the new column containing the extracted URLs. Go to the Home tab, click Conditional Formatting, and choose New Rule.

5
Set the Duplicate Highlighting Rule

Select 'Use a formula to determine which cells to format'. Enter a COUNTIF formula such as =COUNTIF($B:$B,$B2)>1 (assuming your helper column is B). Click Format to choose a fill color, then click OK to highlight all duplicate links.

Extract and Highlight Duplicate Hyperlinks Using a VBA Helper Function
Macro Security: Make sure macros are enabled in your Trust Center settings, otherwise the ShowHyperlink function will return a #NAME? or #VALUE! error.
WPS Spreadsheet Solution

Easily Manage Hyperlinks and Macros with WPS Spreadsheet

WPS Spreadsheet fully supports VBA macros, custom functions, and advanced conditional formatting. You can extract and highlight duplicate hyperlinks seamlessly without altering your normal workflow.

  1. 1. Open Workbook: Open your macro-enabled workbook in WPS Spreadsheet.
  2. 2. Access VBA Editor: Go to the Developer tab and click on 'Macros' or press Alt + F11 to open the VBA Editor.
  3. 3. Add Function: Insert the ShowHyperlink function into a new module.
  4. 4. Use Helper Formula: Use the helper formula =ShowHyperlink() to pull URLs into a new column.
  5. 5. Format Duplicates: Navigate to Home > Conditional Formatting to set your COUNTIF rule for highlighting duplicates.
Fully compatible with Microsoft Excel's .xlsm format and VBA macros.Advanced conditional formatting rules to highlight duplicate data easily.Free and lightweight spreadsheet software with a familiar interface.Supports custom functions to extract underlying URLs effortlessly.
microsoft office alternative - wps office

Frequently Asked Questions

Why doesn't standard conditional formatting find duplicate hyperlinks?

Standard conditional formatting in Excel only evaluates the visible text in a cell. If two identical URLs have different display text (e.g., 'Click Here' vs 'Website'), Excel treats them as unique values and will not flag them as duplicates.

Can I find duplicate hyperlinks without using VBA?

Without VBA, you would need to manually edit and copy each hyperlink address into a helper column, or use third-party add-ins. This is generally too time-consuming for large datasets, making the VBA helper function the most efficient approach.

What does the COUNTIF formula do in the conditional formatting rule?

The COUNTIF formula counts how many times a specific URL appears in the selected column. If the count is greater than 1, it means the URL is duplicated, and the rule applies the highlight formatting to those specific cells.