You will need to loop through the hyperlinks and handle their "parents". If the parent is not a range (could be an object, picture, ...), the code must skip to the next one.
try this
Code:
Option Explicit
Sub remove_hyperlinks_keep_font()
'Erik Van Geit
'070809
Dim ws As Worksheet
Dim h As Hyperlink
Dim a As String
On Error Resume Next
For Each ws In ThisWorkbook.Worksheets
For Each h In ws.Hyperlinks
With h.Parent
a = .Address
If Err Then
Err.Clear
Else
'more code could retrieve the font before deleting the hyperlink
'this code assumes standard settings are applied
h.Delete
.Font.ColorIndex = 5
.Font.Underline = xlUnderlineStyleSingle
End If
End With
Next h
Next ws
End Sub
We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel
Which adblocker are you using?
Disable AdBlock
Follow these easy steps to disable AdBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the icon in the browser’s toolbar. 2)Click on the "Pause on this site" option.
Go back
Disable AdBlock Plus
Follow these easy steps to disable AdBlock Plus
1)Click on the icon in the browser’s toolbar. 2)Click on the toggle to disable it for "mrexcel.com".
Go back
Disable uBlock Origin
Follow these easy steps to disable uBlock Origin
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.
Go back
Disable uBlock
Follow these easy steps to disable uBlock
1)Click on the icon in the browser’s toolbar. 2)Click on the "Power" button. 3)Click on the "Refresh" button.