Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Help with code to run macros from hyperlinks

Hello

I am using the following code to run a macro from a hyperlink located in
cell B13.


Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Not Intersect(Target.Parent, Range("B13")) Is Nothing Then
JacDetailedAnalysisTable
End If
End Sub


The above works fine, but I want to be able to have multiple hyperlinks,
each of which runs a different macro. All of the hyperlinks are on the same
worksheet.

How do I modify the code to achieve this?

I tried repeating the code multiple times, changing the cell reference and
subroutine name for each hyperlink, but this caused all sorts of problems.

Your help would be greatly appreciated.

Thanks,

Joe.
--
If you can measure it, you can improve it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,533
Default Help with code to run macros from hyperlinks

Hi Joe

You can only have one instance of the event code in a workbook, so you have
to make multiple if-then statements within it.

Look at my example:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Not Intersect(Target.Parent, Range("B13")) Is Nothing Then
JacDetailedAnalysisTable
End If
If Not Intersect(Target.Parent, Range("B14")) Is Nothing Then
CallOtherMacro
End If
End Sub

Regards,
Per

"Monomeeth" skrev i meddelelsen
...
Hello

I am using the following code to run a macro from a hyperlink located in
cell B13.


Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Not Intersect(Target.Parent, Range("B13")) Is Nothing Then
JacDetailedAnalysisTable
End If
End Sub


The above works fine, but I want to be able to have multiple hyperlinks,
each of which runs a different macro. All of the hyperlinks are on the
same
worksheet.

How do I modify the code to achieve this?

I tried repeating the code multiple times, changing the cell reference and
subroutine name for each hyperlink, but this caused all sorts of problems.

Your help would be greatly appreciated.

Thanks,

Joe.
--
If you can measure it, you can improve it!


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 63
Default Help with code to run macros from hyperlinks

Hi Per

Thank you VERY MUCH for this. It seems to work perfectly!

To be honest, when I first read it I thought to myself "that's exactly what
I tried and it didn't work" - but obviously I must have missed something
because it works a treat.

Thanks again for your help!

Joe.
--
If you can measure it, you can improve it!


"Per Jessen" wrote:

Hi Joe

You can only have one instance of the event code in a workbook, so you have
to make multiple if-then statements within it.

Look at my example:

Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Not Intersect(Target.Parent, Range("B13")) Is Nothing Then
JacDetailedAnalysisTable
End If
If Not Intersect(Target.Parent, Range("B14")) Is Nothing Then
CallOtherMacro
End If
End Sub

Regards,
Per

"Monomeeth" skrev i meddelelsen
...
Hello

I am using the following code to run a macro from a hyperlink located in
cell B13.


Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
If Not Intersect(Target.Parent, Range("B13")) Is Nothing Then
JacDetailedAnalysisTable
End If
End Sub


The above works fine, but I want to be able to have multiple hyperlinks,
each of which runs a different macro. All of the hyperlinks are on the
same
worksheet.

How do I modify the code to achieve this?

I tried repeating the code multiple times, changing the cell reference and
subroutine name for each hyperlink, but this caused all sorts of problems.

Your help would be greatly appreciated.

Thanks,

Joe.
--
If you can measure it, you can improve it!



Reply
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
hyperlinks and macros Randy[_4_] Excel Discussion (Misc queries) 0 February 2nd 09 07:09 PM
Hyperlinks & macros Mick Links and Linking in Excel 1 January 19th 09 04:57 PM
Hyperlinks & macros Mick Excel Discussion (Misc queries) 0 January 18th 09 08:07 PM
Changing Hyperlinks in Macros Elise148 Excel Discussion (Misc queries) 5 June 22nd 07 05:08 PM
Using filename hyperlinks in Macros [email protected] Excel Programming 7 December 20th 06 11:10 PM


All times are GMT +1. The time now is 01:46 AM.

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

About Us

"It's about Microsoft Excel"