Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / New Users / December 2006

Tip: Looking for answers? Try searching our database.

Syntax to obtain the SubAddress of a Hyperlink in A1 on Sheet1

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dennis - 07 Dec 2006 02:02 GMT
2003

In addition, the best way to separate the Sheetname from the Cell
reference from that SubAddress.

Any thoughts appreciated!

TIA EagleOne
Bob Phillips - 07 Dec 2006 12:14 GMT
With Range("A1").Hyperlinks.Item(1)
       MsgBox Left(.SubAddress, InStr(.SubAddress, "!") - 1)
       MsgBox Right(.SubAddress, Len(.SubAddress) - InStr(.SubAddress,
"!"))
   End With

Signature

---
HTH

Bob

(change the xxxx to gmail if mailing direct)

> 2003
>
[quoted text clipped - 4 lines]
>
> TIA EagleOne
Dennis - 07 Dec 2006 14:53 GMT
As always, another vote for the MVPs.

Thanks EagleOne (Dennis)

> With Range("A1").Hyperlinks.Item(1)
>         MsgBox Left(.SubAddress, InStr(.SubAddress, "!") - 1)
[quoted text clipped - 18 lines]
> >
> > TIA EagleOne
Dennis - 07 Dec 2006 15:21 GMT
Bob,

This form of Hyperlink is volitile:
=HYPERLINK("#"&CELL("address",'Sheet2'!B32),"Click Me")

Above is also the starting-point formula in Cell A1 on Sheet1.

I inserted a row in Sheet2 (changing the linked Cell from B32 to B33)

Now the Formula in Cell A1 Sheet1 is:

=HYPERLINK("#"&CELL("address",'Sheet2'!B33),"Click Me")

This is exactly what I want .... except that:

When I run the Macro:

With Range("A1").Hyperlinks.Item(1)
 MsgBox Left(.SubAddress, InStr(.SubAddress, "!") - 1)
 MsgBox Right(.SubAddress, Len(.SubAddress) - _
       InStr(.SubAddress,  "!"))
End With

The macro returns:

Sheet2
B32    (Which s/b B33)

Is not the subaddress updated when a volitile formula changes?

Plan B

Do a "string" analysis of the current formula to get B33.

What are your thoughts and/or suggestions (to a better approach?)

TIA EagleOne

> With Range("A1").Hyperlinks.Item(1)
>         MsgBox Left(.SubAddress, InStr(.SubAddress, "!") - 1)
[quoted text clipped - 18 lines]
> >
> > TIA EagleOne
Bob Phillips - 07 Dec 2006 15:55 GMT
I don't undedrstand why you are getting a result at all, the code looks at
the hyperlinks coolection, but by using that formula, you haven't created
one. It should fail.

However, to get whata you want, I think that you have to parse it

Dim sTmp As String
With Range("A1")
   sTmp = Replace(Mid(.Formula, InStr(.Formula, "CELL("), InStr(.Formula,
")") - InStr(.Formula, "(") - 5), _
           "CELL(""address"",", "")
   MsgBox Left(sTmp, InStr(sTmp, "!") - 1)
   MsgBox Right(sTmp, Len(sTmp) - InStr(sTmp, "!"))
End With

Signature

---
HTH

Bob

(change the xxxx to gmail if mailing direct)

> Bob,
>
[quoted text clipped - 56 lines]
>> >
>> > TIA EagleOne
Dennis - 07 Dec 2006 16:22 GMT
Looks like our last posts were almost simultanious.

Thank you for your help and knowledge.  As you see, I really do try to
do my own
work and not burden others with my work.  That said, you and the others
are a gift to the learning process.

EagleOne

> I don't undedrstand why you are getting a result at all, the code looks at
> the hyperlinks coolection, but by using that formula, you haven't created
[quoted text clipped - 79 lines]
> >> >
> >> > TIA EagleOne
Dennis - 07 Dec 2006 16:33 GMT
The "reason" that I did get a result was this:
I replaced a pre-existing Hyperlink formula (only) with the volitile
version.  I hit return and did not realize that the hyperlink
information was still in the collection.

Therefore, I went back and removed the link and the world is back in
balance.

EagleOne

> I don't undedrstand why you are getting a result at all, the code looks at
> the hyperlinks coolection, but by using that formula, you haven't created
[quoted text clipped - 79 lines]
> >> >
> >> > TIA EagleOne
Bob Phillips - 07 Dec 2006 17:46 GMT
I'm glad about that <g>. The world was definitely a-kilter for a moment.

Bob

> The "reason" that I did get a result was this:
> I replaced a pre-existing Hyperlink formula (only) with the volitile
[quoted text clipped - 92 lines]
>> >> >
>> >> > TIA EagleOne
Dennis - 07 Dec 2006 15:53 GMT
Bob,

This is what I came up with:

   With Range("A1")
       BeginStr = Len(Left(.Formula, InStr(.Formula, "!") + 1))
       SecondStr = InStr(BeginStr, .Formula, ")")
       CellRef = Mid(.Formula, BeginStr, SecondStr - BeginStr)
       MsgBox CellRef
   End With

That said, I would like to know why the SubAddress information was not
updated permitting your macro to return the updated SubAddress, if in
fact, it ever is updated.

TIA  EagleOne

> With Range("A1").Hyperlinks.Item(1)
>         MsgBox Left(.SubAddress, InStr(.SubAddress, "!") - 1)
[quoted text clipped - 18 lines]
> >
> > TIA EagleOne

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.