Prevent Auto-Hyperlinking In Excel

Prevent Autocorrect Hyperlink In Excel

By default Excel will convert text to a hyperlink if it determines your data is in a URL or email address format. This is typically not a wanted behavior inside spreadsheets and in this article you will learn a couple ways to prevent this type of auto-correction from occurring within Excel.

Below is an example of what you would see if you entered in text for search engine websites and email addresses.

Spreadsheet Example.png

The problem with these hyperlinks (and most likely why you are reading this article) is if you just want the data, it can be a pain to work around the links while making manipulations. In order to select a cell with a hyperlink, you need to use your right mouse button instead of your left.

So lets dive in and see how we can prevent this from occurring in the first place!

Excel-Level Change

First, let’s look at a setting we can tweak to change this auto-correction task across the entire Excel application. This means this change will impact every workbook on your machine.

In Excel >> File Tab >> Options Menu >>

  1. Select Proofing from the side-pane

  2. Click the AutoCorrect Options… button

  3. Navigate to the AutoFormat As You Type tab

  4. Uncheck Internet and network paths with hyperlinks under Replace as you type

  5. Click OK to confirm the change

Prevent Autocorrect Hyperlink In Excel
Prevent Autocorrect Hyperlink In Excel

Worksheet-Level Change

Now let’s take a look at how we can use VBA to prevent auto-hyperlinking at the worksheet level. The following code will use Excel Events to trigger the VBA. We will utilize the Change event to run this bit of code every time a cell’s value changes on the target worksheet. If you would like to learn more about triggering VBA code when something on the worksheet changes, you can read my more detailed blog post: How To Trigger Your VBA Macros To Run Based On A Specific Cell Value Change.

Preventing New Hyperlinks With VBA

The following snippet will need to be pasted inside your desired Sheet Object using the Visual Basic Editor. It will look at only the range of cells that were last changed and remove any hyperlinks located within that range.

Private Sub Worksheet_Change(ByVal Target As Range)
'PURPOSE: Prevent any new hyperlinks from auto-generating
'NOTE: Manually adding hyperlinks can still be done

If Target.Hyperlinks.Count <> 0 Then Target.Range.ClearHyperlinks

End Sub

Preventing Any Hyperlinks With VBA

If you absolutely don’t want to have any hyperlinks on your sheet, we can use a more encompassing piece of code. The following VBA subroutine will need to be pasted inside your desired Sheet Object using the Visual Basic Editor. This code will remove any hyperlinks on the spreadsheet when a change is made.

Private Sub Worksheet_Change(ByVal Target As Range)
'PURPOSE: Prevent any hyperlinks ever occuring within this spreadsheet

'Remove All Hyperlinks From Cells In This Sheet
  Me.Cells.ClearHyperlinks

End Sub

Any Other Solutions?

Have your discovered any other methods we can take inside Excel to prevent hyperlinks? Let me know in the comments section below.