Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you preserve cell formatting when removing a hyperlink with Excel VBA?

Tags:

excel

vba

Removing a hyperlink from a cell also removes formatting.

Selection.Hyperlinks.Delete

Is there a way to preserve the formatting, or do I need to reapply it after removing the hyperlink?

like image 626
Jon Crowell Avatar asked May 14 '12 15:05

Jon Crowell


1 Answers

I found the solution was to call

Range.ClearHyperlinks

instead of

Range.Hyperlinks.Delete

the former clears the hyperlinks and leaves the formatting intact. Reference here: https://msdn.microsoft.com/en-us/library/office/ff194741.aspx

like image 65
Symen Avatar answered Nov 15 '22 08:11

Symen