View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
joel joel is offline
external usenet poster
 
Posts: 9,101
Default Hyperlink with Code

You can get the sheet name frok the hyperlink rather than actual activating
the hyperlink. See code below

Sub test()

Set linkcell = Sheets("Sheet1").Range("D1")
DestAddr = linkcell.Hyperlinks.Item(1).SubAddress

If InStr(DestAddr, "!") 0 Then
ShtName = Left(DestAddr, InStr(DestAddr, "!") - 1)
Set DestAddr = Sheets(ShtName)
Else
Set DestAddr = ActiveSheet
End If


End Sub


"James" wrote:

is there a way to have a hyperlink that also can then run a subroutine.
The hyperlink is from one worksheet to another in the same workbook.
After the hyperlink is selected I would then like to call my subroutine that
copys data to the destination worksheet.
I would prefer to use a hyperlink as opposed to a command button because the
cell(s) that will have the hyperlinks are small and I don't want all these
very small command buttons. Thanks