# Microsoft Office Application Help - Excel Help forum > Excel Programming / VBA / Macros >  > [SOLVED] Checking for broken hyperlinks

## ChrisMattock

Good morning all, 

I am putting together a document where often the numbers have to be justified by some form of supporting document, often in .pdf format. To be as user friendly as possible I hyperlink those numbers to said document. Unfortunately that means there are a lot of hyperlinks and mistakes get made! 

So my question is, is there a way to automatically check the entire document to ensure none of the links are broken, and if there are broken links, which ones they are? Thanks in advance! 

Chris

----------


## Ron Coderre

Assuming the hyperlinks refer to documents on your network...
Try this

• Select any sheet in the workbook you want to test
• ALT+F11....to open the VBA Editor
• Insert.Module
• Copy the below code and paste it into that module



```
Please Login or Register  to view this content.
```




• Select a sheet that contains hyperlinks you want tested.
• Select the range of cells that contains the hyperlinks....eg A1:Z100
• ALT+F8...to open the list of availlable macros
• Select: TestHLinkValidity
• Click: Run

Any hyperlinks with invalid targets will be colored yellow.

Is that something you can work with?

----------


## ChrisMattock

Thanks for the help Ron, that works brilliantly!

----------


## jladyj

This worked great for finding existing, unbroken hyperlinks. Now I want to find cells in the range that don't have hyperlinks and highlight those. Any suggestions? :Wink:

----------


## bcolson

Tried it. All my links were colored yellow. Half of the hyperlinks actually work and the other half don't but the macro says they all are invalid.

----------


## Nick Hindriks

Having the same problem.





> Tried it. All my links were colored yellow. Half of the hyperlinks actually work and the other half don't but the macro says they all are invalid.

----------


## abousetta

Welcome to the Forum, unfortunately:

_Your post does not comply with Rule 2 of our Forum_ RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

Also, for confirmation, I believe Ron's code is for documents on a network. If you are at URLs then there is other code for this. It was not clear from your post which you were trying to check.

PM me if you have any problems.

abousetta

----------


## michellebest

Thanks this macro worked great for me!

----------


## ryan_linz

Hi, Ron.

This worked marvelously for me but I have one question.

Is there a way to run this on hyperlinks that are attached to images instead of hyperlinks that are attached to cells?  

This MACRO is skipping the cells with said image hyperlinks (I have intentionally made some of the links incorrect to verify this).

Each cell in the column has a little document thumbnail image which is what the hyperlink is actually linked to and I'm looking to verify that they will, in fact, open.

Thank you so much!

----------


## arlu1201

ryan_linz,

Welcome to the Forum, unfortunately:

_Your post does not comply with Rule 2 of our Forum_ RULES. Don't post a question in the thread of another member -- start your own thread. If you feel it's particularly relevant, provide a link to the other thread. It makes sense to have a new thread for your question because a thread with numerous replies can be off putting & difficult to pick out relevant replies.

----------


## Solved It

This cleaner version will fix it. Ron just forgot to use the entire path. Looks like caused by copying only portions of another code (hence the superfluous variables). Good algorithm though.




```
Please Login or Register  to view this content.
```

----------


## arlu1201

Solved it,

Welcome to the forum and thank you for the solution.

I have added *code tags* to your post.  As per forum rule 3, you need to use them whenever you put any code in your post.  Please add them in future.  If you need more information on how to use them, check my signature below this post.

----------


## safala

hi there I have checked all the codes you mentioned above for broken web hyperlinks. But still There are some links in my file which are not broken but code showing them broken.

----------


## maat.plant

Didn't work for me, all the links are still broken...

----------


## danialadam

Try this




```
Please Login or Register  to view this content.
```

----------


## arlu1201

Danialadam,

Welcome to the forum.

I have added *code tags* to your post.  As per forum rule 3, you need to use them whenever you put any code in your post.  Please add them in future.  In order to put code tags, either type  [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE]  at the end of it, OR you can highlight your code and click the *#* icon at the top of your post window.

----------


## watchoverme

> Assuming the hyperlinks refer to documents on your network...
> Try this
> 
>  Select any sheet in the workbook you want to test
>  ALT+F11....to open the VBA Editor
>  Insert.Module
>  Copy the below code and paste it into that module
> 
> 
> ...



After I press ALT + F11 where do I type Insert.Module and the code?

----------


## watchoverme

As per Ron's instructions, after I press ALT+F11 to open the VBA Editor where would I type in Insert.Module?  I just get a blank screen.  And where would I paste the code into the module?  

Any help would be appreciated.

----------


## arlu1201

After you press Atl+F11, on the left hand side you will Microsoft Excel Objects.  Right click on it and select Insert - > Module.  On the right hand side you will see a blank code window.  Copy paste your code over there.

----------


## Corey123

Thank you Ron, Yours worked a treat for me... with one exception lol 
It will tell me of broken links into a specific file, but some of my links are into folders containing a list of files and are highlighted as broken when in fact they work as intended. 
If you or anyone else could help with this i'd be very appreciative. 

Sorry "Solved it" and "Danialadam" i tried yours, they both just highlight a hyperlink if its working or not.

----------


## protonLeah

Corey123,
Unfortunately _your post does not comply with Rule 2 of our Forum_ RULES. *Do not post a question in the thread of another member -- start your own thread.* 

If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread. 

Old threads are often only monitored by the original participants.  New threads not only open you up to all possible participants again, they typically get faster response, too.

----------


## chrisfreire

I keep getting this error message:

"Run-time error'429':
ActiveX component can't create object"

----------


## protonLeah

chrisfreire,
Unfortunately _your post does not comply with Rule 2 of our Forum_ RULES. *Do not post a question in the thread of another member -- start your own thread.* 

If you feel an existing thread is particularly relevant to your need, provide a link to the other thread in your new thread. 

Old threads are often only monitored by the original participants.  New threads not only open you up to all possible participants again, they typically get faster response, too.

----------


## muhamed.zeid

will try it as I really need something like this

----------


## Prem.Ramesh

It's Really Superb man.. Thankz A lot

----------


## SindhuK

Thank you. It worked great.

----------


## Nylvada

For me the previous examples continue to highlight all of the hyperlinks, not just the broken ones.
This is what worked for me after adding a reference to Microsoft WinHTTP Services under Tools > References:



```
Please Login or Register  to view this content.
```

----------

