LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default How to extract "destination address" from Hyperlink - VBA

Hi,

I have following function:

Function HL_SheetName(komorka As Range) As String
If komorka.Hyperlinks.Count = 0 Then
Exit Function
End If
Dim poz As Integer
HL_SheetName = komorka.Hyperlinks(1).SubAddress
poz = InStr(1, HL_SheetName, "!")
poz = poz - 1
HL_SheetName = Mid(HL_SheetName, 1, poz)
poz = InStr(1, HL_SheetName, "'")
If poz = 1 Then
poz = Len(HL_SheetName)
poz = poz - 2
HL_SheetName = Mid(HL_SheetName, 2, poz)
End If
End Function

This function returns SubAddress from hyperlink ( actually name of the
Sheet ).
It works, but sometimes I get wrong sheet name, and hyperlink works
well.
For example:

Cell A1 have hyperlink to Sheet2!A1.
I enter the formula in B1: HL_SheetName(A1) , and I get in B1: Sheet2.

Cell A2 have hyperlink to Sheet3!A1.
I enter the formula in B2: HL_SheetName(A2) , and I get in B2: Sheet2.

WTF??
Both hyperlinks works fine.
I don't understand.

With the hyperlinks(1).TextToDisplay is the same situation...

Where exactly is the destination address in the structure of
hyperlink? ( SubAddress, Address , ..... ?? )
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
=HYPERLINK("#"&CELL("address", ADDRESS(MATCH(VALUE(B3),QuoteNotes, sarah Excel Worksheet Functions 2 February 17th 09 02:59 PM
=HYPERLINK("#"&CELL("address", ADDRESS(MATCH(VALUE(B3),Range ... ? sarah Excel Worksheet Functions 0 February 17th 09 02:06 PM
How do I create a macro to remove path from hyperlink "address"? Ale Excel Discussion (Misc queries) 7 March 31st 08 06:48 PM
Multiple "source" workbooks linked to single "destination" workboo DAVEJAY Excel Worksheet Functions 1 September 17th 07 05:33 PM
VBA code store address with areas separated with "," and I need it sometimes with ";" instead tskogstrom Excel Programming 2 June 17th 07 04:14 AM


All times are GMT +1. The time now is 11:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"