ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Removing hyperlink without removing the font settings /border sett (https://www.excelbanter.com/excel-programming/398248-removing-hyperlink-without-removing-font-settings-border-sett.html)

San

Removing hyperlink without removing the font settings /border sett
 
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

Tom Ogilvy

Removing hyperlink without removing the font settings /border sett
 
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

--
Regards,
Tom Ogilvy

"San" wrote:

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


Gary''s Student

Removing hyperlink without removing the font settings /border sett
 
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

--
Gary''s Student - gsnu200747


"San" wrote:

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



All times are GMT +1. The time now is 05:23 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com