Removing hyperlink without removing the font settings /border sett

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

The below code removes hyperlinks
Sub ZapHyperlinks()
Cells.Hyperlinks.Delete
End Sub
However it also removes the formatting(color/border) of the cell .
Any idea on how to protect the format of the cell
 
Maybe something like this:

Sub ZapHyperlinks()
Set sh = ActiveSheet
ActiveSheet.Copy After:=Worksheets(Worksheets.Count)
Set sh1 = ActiveSheet
sh.Activate
Set r = Selection
Cells.Hyperlinks.Delete
sh1.Cells.Copy
sh.Cells.PasteSpecial xlFormats
r.Select
Application.DisplayAlerts = False
sh1.Delete
Application.DisplayAlerts = True
End Sub
 
Another way:

Sub hyper_be_gone()
For Each r In ActiveSheet.UsedRange
If r.Hyperlinks.Count > 0 Then
r.ClearContents
End If
Next
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top