Solved

Macro for removing hyperlinks from spreadsheet

Posted on 2007-11-20
5
1,778 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Sparklines have been introduced with Excel 2010 and are a useful tool for creating small in-cell charts, used for example in dashboards. Excel 2010 offers three different types of Sparklines: Line, Column and Win/Loss. What it does not offer is a…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial will demonstrate how to use longer labels with horizontal bar charts instead of the vertical column chart.

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now