Reputation: 5752
I have some cells that contain hyperlinks. The hyperlinks have leading blanks. If I use TRIM, the result returned is just a text, not a hyperlink.
Is there a worksheet function (not vba) that can remove the leading blanks and retain the functionality of the hyperlink?
Example: ____Link1Text (where ___ are blanks and link1Text is a hyperlink in a cell).
Thank you.
Upvotes: 2
Views: 2367
Reputation: 60224
You can try:
=HYPERLINK(TRIM(A1))
However, if Link1Text
(without the leading spaces) is not the actual URL or full file path, then the Excel formula will not work. You'll need a VBA routine to extract the actual hyperlink address. If that is the case, then try this UDF (User Defined Function):
Function GetHyperlink(RG As Range) As String
GetHyperlink = RG.Hyperlinks(1).Address
End Function
and then use this formula in the cell:
=HYPERLINK(GetHyperlink(A1),TRIM(A1))
Upvotes: 2