Nilesh’s Weblog

August 18, 2008

Hyperlinks in Excel

Filed under: Microsoft Excel — Tags: , — deshnilesh @ 5:12 pm

Well here’s one more excel trick which I learned today. I had a file which was having hyperlinks to all of its cells and I wanted to get rid of it. Here’s the code which will do it for you in seconds!! -

Sub RemoveAllHyperlinks()
‘Remove all hyperlinks from the active sheet
ActiveSheet.Hyperlinks.Delete
End Sub

If you want to remove Hyperlinks from all the sheets then just add a loop to browse thru all sheets and then remove the hyperlinks or write a procedure to browse thru the sheets and then call above procedure.

Sub RemoveAllHyperlinksFromAllSheets()
‘Remove all hyperlinks from all sheet
Dim varSheet As Worksheet
For Each varSheet In ActiveWorkbook.Worksheets
varSheet.Hyperlinks.Delete
Next
End Sub

What if you want to remove hyperlinks for a particular range? That is also not a problem just select the cells and run the code -

Sub RemoveHyperlinksForSelectedCells()
‘Remove all hyperlinks from selected cells
For Each cell In Selection
cell.Hyperlinks.Delete
Next
End Sub

Blog at WordPress.com.