Solved

Macro for removing hyperlinks from spreadsheet

Posted on 2007-11-20
5
1,782 Views
Last Modified: 2010-04-21
Hi Experts,
I have an Excel spreadsheet that has hyperlinks randomly scattered in different cells within the spreadsheet, is there a way of having a macro that can remove all hyperlinks in the spreadsheet. Thanks
Sam
0
Comment
Question by:samirst
5 Comments
 
LVL 6

Accepted Solution

by:
chipconsult earned 250 total points
ID: 20318692
This will delete the hyperlink but the text will remain.

Sub test()
For Each hp In ActiveSheet.Hyperlinks
 hp.Delete
Next hp

End Sub

Claus Henriksen
0
 
LVL 81

Assisted Solution

by:zorvek (Kevin Jones)
zorvek (Kevin Jones) earned 250 total points
ID: 20318695
Public Sub RemoveHyperlinks()

   Dim Hyperlink As Hyperlink
   Dim Count As Long
   
   For Each Hyperlink In ActiveSheet.Hyperlinks
      Hyperlink.Delete
      Count = Count + 1
   Next Hyperlink
   
   MsgBox Count & " hyperlinks deleted."

End Sub

Kevin
0
 

Author Closing Comment

by:samirst
ID: 31410090
Guys, both solutions worked perfectly and have the exact timestamp when posted. So the best option is to split the points equally. Many thanks for your help.
Sam
0
 
LVL 85

Expert Comment

by:Rory Archibald
ID: 20318747
Sub RemoveHyperlinks()
ActiveSheet.Hyperlinks.Delete
End Sub

will also do it.
Regards,
Rory
0
 
LVL 6

Expert Comment

by:chipconsult
ID: 20318985
A little add-on:
If you want to delete the text as well it is done with:

Sub RemoveHyperlinks()

For Each hl In ActiveSheet.Hyperlinks

    Range(hl.Range.Address).ClearContents

Next hl

End Sub

Claus Henriksen
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question