sspatriots
Well-known Member
- Joined
- Nov 22, 2011
- Messages
- 585
- Office Version
- 365
- Platform
- Windows
I'm trying to convert several hyperlink formulas to anchored hyperlinks with just the text value left in the cell. The code I have so far only does the top cell in the range (selected cells in a column), but it also renames the value in the top cell to the actual value in the bottom cell of the selected range. Then the rest of the cells in the selected range won't loop through and take out the hyperlink formulas. Any ideas would be appreciated. Thanks, SS
I wanted to add that if I just select one cell with a hyperlink formula in it, the code will work on that one cell.
I wanted to add that if I just select one cell with a hyperlink formula in it, the code will work on that one cell.
VBA Code:
Sub convert_hyperlink_formula_to_hyperlink_cell()
Dim address_string As String, display_string As String
Dim current_range As Range
Dim cel As Range
Set current_range = Application.Selection
For Each cel In current_range.Cells
Debug.Print cel.Address, cel.Value
address_string = Mid(cel.Formula, 13, InStr(19, cel.Formula, ".") - 9)
display_string = cel.Value
ActiveSheet.Hyperlinks.Add Anchor:=cel, Address:=address_string, TextToDisplay:=display_string
ActiveCell.Value = display_string
Next cel
End Sub