ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Links and Linking in Excel (https://www.excelbanter.com/links-linking-excel/)
-   -   Extract hyperlink string from excel cell (https://www.excelbanter.com/links-linking-excel/553-re-extract-hyperlink-string-excel-cell.html)

Ryan Sapien

Extract hyperlink string from excel cell
 
Forgive my ignorance but I haven't done a lot of work with Excel VBA.
So do I just have to paste the function into the VBA window and then
add =HyperLinkText(CellName) on my worksheet cell?

Thanks

Ryan


Bill Manville wrote:
Markus Riester wrote:
Is there a function that is available (I didn't find one
in the standard functions Excel offers), or does anyone
have a macro?

Something like this?

Function HyperLinkText(oRange As Range) As String
Dim ST1 As String, ST2 As String
If oRange.Hyperlinks.Count = 0 Then Exit Function
ST1 = oRange.Hyperlinks(1).Address
ST2 = oRange.Hyperlinks(1).SubAddress
If ST2 < "" Then ST1 = "[" & ST1 & "]" & ST2
HyperLinkText = ST1
End Function


Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup



Bill Manville

Ryan Sapien wrote:
So do I just have to paste the function into the VBA window and then
add =HyperLinkText(CellName) on my worksheet cell?


Yes
In the VB editor you need to Insert / Module if there are no standard
modules already in your workbook. Then paste the code into that
module.

Bill Manville
MVP - Microsoft Excel, Oxford, England
No email replies please - respond to newsgroup



All times are GMT +1. The time now is 11:29 AM.

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