Incorrect Links after Sorting Hyperlinks

by Allen Wyatt
(last updated March 12, 2018)


Susan has a worksheet with cells hyperlinked to corresponding PDF documents. The hyperlinks work fine until she attempts to perform any type of sorting on the data in the worksheet. After sorting, the hyperlinks are linked to incorrect documents.

This is, apparently, a problem with Excel under some circumstances. According to Microsoft, this occurs if you copy and paste cells containing hyperlinks and then sort the pasted cells. You can find out a bit more about this problem at the following Knowledge Base page:

The problem is, the only solution noted by Microsoft is to manually correct the hyperlinks after doing the sort that created the messed-up links. In other words, there isn't a real solution.

ExcelTips is your source for cost-effective Microsoft Excel training. This tip (13063) applies to Microsoft Excel 2007, 2010, and 2013.

Author Bio

Allen Wyatt

With more than 50 non-fiction books and numerous magazine articles to his credit, Allen Wyatt is an internationally recognized author. He  is president of Sharon Parq Associates, a computer and publishing services company. ...


Delivery Address Won't Print on Envelopes

Word includes a feature that allows you to easily create and print envelopes, based on the addresses you insert in your ...

Discover More

Using Microsoft Fix It

Got a program on your system that you can't get rid of? Here's a handy little program that Microsoft provides that may be ...

Discover More

Adding a Horizontal Watermark with a PostScript Printer

In Windows, printer drivers translate formatting into a printer control language, like PostScript, that the printer ...

Discover More

Solve Real Business Problems Master business modeling and analysis techniques with Excel and transform data into bottom-line results. This hands-on, scenario-focused guide shows you how to use the latest Excel tools to integrate data from multiple tables. Check out Microsoft Excel 2013 Data Analysis and Business Modeling today!

More ExcelTips (ribbon)

Sorting IP Addresses

If you keep track of IP addresses in an Excel worksheet, you probably already know that it is difficult to sort those ...

Discover More

Sorting Text as Numbers

When you are sorting by text values, Excel can be very literal, which may not get you the sorting that you want. This tip ...

Discover More

Sorting a Range of Cells

When you sort data in a worksheet, you don't need to sort everything at once. You can sort just a portion of your data by ...

Discover More

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

View most recent newsletter.


If you would like to add an image to your comment (not an avatar, but an image to help in making the point of your comment), include the characters [{fig}] in your comment text. You’ll be prompted to upload your image when you submit the comment. Maximum image size is 6Mpixels. Images larger than 600px wide or 1000px tall will be reduced. Up to three images may be included in a comment. All images are subject to review. Commenting privileges may be curtailed if inappropriate images are posted.

What is 1 + 5?

2018-02-26 21:30:40


I just figured out a solution using Excel 2010 that allows sorting without corrupting the links. It has the added benefit of adding only 1 or 2 columns and works in either case. Add 1 column headed "URL" and if desired a second column headed "Display". In the column where you want the hyperlink to be clickable, use the HYPERLINK formula to refer to the URL (and if used, the Display column).
Example: =HYPERLINK(A5,B5)
As long as the data is sorted contiguously, the links will not break/scramble and will remain clickable. If you want to use just the URL column, then remember to modify the link formula to =HYPERLINK(A5,"friendly_name").
(see Figure 1 below)

Also: If you can salvage the URLs from your messed up links, you could reconstruct the hyperlinks using this method rather than doing it one by one.

Figure 1. 

2017-10-31 16:55:34



To answer Jennifer - yes this problem still applies to Excel 2010 and 2013 (I don't have 2016).
To answer Fred - I had the same problem with hundreds of hyperlinks that I had copied and pasted.
To answer Gary - HYPERLINK function has to be applied to each individual cell and it will sort OK. But copy that cell further down the column and the problem occurs with incorrect sorting.

The method Gary suggest involves extra cells. I needed a worksheet with minimum columns where the pdf filename could just be clicked on to take the user to the pdf, over 1100 links in total. I found the problem about half way through creating the worksheet! The only way I could make it be sortable without scrambling the links was to recreate each hyperlink individually.

As I said below, Open Office could sort them fine, but my client may not have had Open Office. Excell fails badly and I would have been in real problems sending out a spreadsheet that scrambles if someone sorts it.

2017-10-25 11:07:18


I don't use the hyperlink feature, instead using the HYPERLINK function (in the desired cells), and use relative cell addresses. Additionally, the HYPERLINK function is pointed to a "data" cell/column that contains the link path/filename. This filename cell/column is then included in the sort range. With this technique I have never had a problem with links pointing to incorrect documents after sorting. As a side note, I also use a macro to select the desired file to then load into the "data" cell.

Alternately you could also just paste the full path/filename (in-quotes) in the HYPERLINK function and it will also work.

Example: In cell B4 enter the formula -
=HYPERLINK(B8, "PDF") Just make sure any 'sort' you perform includes up to column 8 in this case.
=HYPERLINK("D:\Data\Contracts\Test Data.pdf", "PDF")

2017-10-25 08:11:04

Jennifer Thomas

The Microsoft article forgot to include an 'Applies to' section (at least I didn't see one using IE11). It does say it's last update was in 2008 - does anyone know if this is still a problem in 2007+ versions of Excel?

2017-04-16 08:06:19


Open Office 4.1.1 can do this sort OK. Microsoft should go figure how they can do it for free.

2016-01-29 13:55:54


I think the issue still exists in Excel 2010. I copied and pasted hundreds of hyperlinks and they are messed up after sorting the spreadsheet. :(

2015-07-17 14:08:14


My hyperlinks are in a project dashboard and are never subject to getting sorted. But they still get broken.
My links generally are to a specific project folder or document on the server that never move.

2015-06-05 06:36:08


I use Hyperlinks from one cell to another in the same file. If I sort the date, the hyperlinks are all messed up. Is there a workaround?

2015-04-08 09:32:13


Put the time into to create each hyperlink individually (do not copy a hyperlink) and it will sort fine!

2014-10-07 10:09:39


Were you able to test barouh's solution?

Creating the hyperlink using the HYPERLINK() function will "display" the named document (in my case a pdf file) but it does not open it; whereas using the "Hyperlink" from the ribbon Insert tab/Links group and "inserting" a hyperlink, automatically will open the pdf file I'm hyperlinking to. I hope this makes sense...
So, I guess the moral of the story is you have a choice: you can either choose to display only the named document you're linked to and leave it to the end user to open the document for viewing and you can keep the sort function performing properly (OR) you can have your linked document open automatically and choose to never be able to use the sort function without breaking all your hyperlinks...not a very fair trade-off if you ask me! Using Excel 2013, and with Microsoft knowing about this already PRIOR to Excel 2007, you would have thought Microsoft would have fixed this by now.

2014-06-03 23:44:18


This is absurd. I really need these links, I have hundreds of rows, and I can't manually repair each link every time I sort. What, if anything, was Microsoft thinking?

You said something really intriguing, but I couldn't quite understand. Could you please say again what you did to prevent the hyperlinks from being separated from their cells during sorting?

2014-04-16 18:59:04


My version of Excel is 2013. However, I previously was using version 2010 and experienced the same hyperlink issues.
When I create the hyperlink I simply right click on the cell and choose "hyperlink" and continue the process from there.
I do not cut/copy and paste the hyperlinks...I create all of them using the hyperlink wizard .

2014-04-16 10:42:54

Glenn Case


It appears to be fixed in 2010; at least I just tried cutting/pasting a list of hyperlinks, then soprting, and the hyperlinks still referred to the correct file.

2014-04-14 02:28:29


This is not a solution to repair the mess after the sorting, but at least easy way to prevent such problems in future: if hyperlink addresses are stored in separate column just as text values, and active hyperlinks are created by HYPERLINK() function, referring to that column with text values, than - I believe - sorting will not break anything

2014-04-12 10:37:07


Was this problem fixed in Excel 2010? The Knowledge Base article says it applies to all version of Excel through 2007, but the last review date for the article was January 16, 2007!

This Site

Got a version of Excel that uses the ribbon interface (Excel 2007 or later)? This site is for you! If you use an earlier version of Excel, visit our ExcelTips site focusing on the menu interface.

Newest Tips

FREE SERVICE: Get tips like this every week in ExcelTips, a free productivity newsletter. Enter your address and click "Subscribe."

(Your e-mail address is not shared with anyone, ever.)

View the most recent newsletter.