I'm not very good with Excel but I'm going to try and explain my problem. Somehow an excel was created via a Timer and somehow has 100's of invisible hyperlinks spread throughout the sheet. I am trying to find a way to copy from A1:k50 remove all hyperlinks but keep the formulas, values, and format. I found this code online, and I've tried adding HR.PasteSpecial xlPasteFormulas but that doesnt seem to work. Any thoughts/ideas would be much appreciated.
Sub RemoveHlinks()
'Remove hyperlinks from selected cells without
'removing the cell formatting.
Dim Hlink As Hyperlink
Dim HR As Range
Dim Temp As Range
Dim MaxCol As Integer
With ActiveSheet.UsedRange
MaxCol = .Column + .Columns.Count
End With
Set Temp = Cells(1, MaxCol)
For Each Hlink In Selection.Hyperlinks
Set HR = Hlink.Range
HR.Copy Destination:=Temp
HR.ClearContents
Set Temp = Temp.Resize(HR.Rows.Count, HR.Columns.Count)
Temp.Copy
HR.PasteSpecial xlPasteFormats
HR.PasteSpecial xlPasteValues
Temp.Clear
Next Hlink
End Sub
I was also wondering why, but upon reading through the lines this code actually works, all you need to do is to follow the note mentioned:
'Remove hyperlinks from selected cells without 'removing the cell formatting.
i.e. Highlight/select the column (or cells) and run the code
Voila, Hyperlinks removed while format retained.
Dennis
(edited)
I believe you will have to copy every property in each cell (hope there's no merged ones, that would cause additional troubles), then delete it's hyperlink, and after that restore the propertyes.
You can record macros to discover all that properties, here is some example with fonts and interior. To discover wich other properties you might need to do that, you will have to start recording a macro, select some cell, change that properties manually, stop recording, and see in generated code what that properties are.
(original) You could simply copy everything manually or automatically (including hyperlinks). And in the new sheet where you paste those things, just delete the hyperlinks using:
Selection.Hyperlinks.Delete