View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default call a sub with arguments from Worksheet_FollowHyperlink event

It should have been subaddress without the external:=true - went braindead
for a while.

but that didn't work in my test - gave me another type of error - as
suggested, I think it is fighting the event. Anyway, this worked:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Application.OnTime Now, "Dummy"
End Sub


now create, in a general module, a sub named dummy

Sub Dummy()
CenterOnCell ActiveCell
End Sub


An alternative would be to use the beforedoubleclick event or even selection
change for a cell and skip the hyperlink.

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As
Boolean)
If Target.Address = "$E$5" Then
Cancel = True
CenterOnCell Worksheets("Sheet3").Range("Z35")
End If
End Sub

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Address = "$E$6" Then
CenterOnCell Worksheets("Sheet3").Range("Z35")
End If
End Sub

use one or the other.
You could format the cell to look like a hyperlink if you are using
selection change or for beforedoubleclick, put in text like

doubleclick to go to Z35




--
Regards,
Tom Ogilvy


"Jay Fincannon" wrote in message
...
Tom
I get Wrong number of arguments or invalid property assignment (Error
450) Error breaks at .Address, the Hyperlink address is "", I tried
using the SubAddress but that didn't work either.
CenterOnCell works ok if called from other than a Hyperlink.
on inspection I know the cell i need to goto. even tried hard coding
Call CenterOnCell ($B$415) that didn't work either.
Jay

On Tue, 26 Aug 2003 12:02:43 -0400, "Tom Ogilvy"
wrote:

CenterOnCell Range(Target.Address(External:=True)

Although, the centeroncell may be fighting the hyperlink - you might have

to
adjust Chips code.