Incorrect Links after Sorting Hyperlinks

by Allen Wyatt
(last updated October 25, 2017)

14

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:

http://support.microsoft.com/kb/214328

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. ...

MORE FROM ALLEN

Changing the Orientation of Your Chart

Microsoft Graph is a great way to add simple charts to your documents. Once you've got a graph added, you might want to ...

Discover More

Tab Key Jumps a Screen at a Time

Have you ever pressed the Tab key, expecting to move to the next cell in your worksheet, only to have Excel completely change ...

Discover More

Adjusting Column Width from the Keyboard

It's easy to adjust the width of table columns using the mouse, but what if you don't want to use the mouse? Adjusting column ...

Discover More

Excel Smarts for Beginners! Featuring the friendly and trusted For Dummies style, this popular guide shows beginners how to get up and running with Excel while also helping more experienced users get comfortable with the newest features. Check out Excel 2013 For Dummies today!

More ExcelTips (ribbon)

Sorting by the Last Digits in Variable Length Data

Excel is great at sorting information in a worksheet. Sometimes it can be a bit confusing as to how to set up the sort based ...

Discover More

Sorting Dates by Month

Sorting by dates is easy, and you end up with a list that is in chronological order. However, things become a bit more tricky ...

Discover More

Fixing Odd Sorting Behavior

When you sort data that contains both numbers and text, you may not get exactly the result that you expected. To know what is ...

Discover More
Subscribe

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

View most recent newsletter.

Comments

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 3 + 8?

2017-10-31 16:55:34

Quentin

Hi

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

Gary

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.
or
=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

Quentin

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

Fred

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

steve

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

Lemmer

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

Jono

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

Susan

Michael:
Were you able to test barouh's solution?

barouh:
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

Michael

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?

Barouh:
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

Susan

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

Jerry:

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

barouh

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

Jerry

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
Subscribe

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.