That did the tirck. Thanks.
"Gary''s Student" wrote:
Good question!
If you put:
MsgBox Target.Parent.Address
It will display the cell address in Sheet1 that was clicked (where we came
from)
You can then put some If's or a Select Case statement in the code to do
different thing based upon which hyperlink was clicked.
--
Gary''s Student - gsnu200903
"James" wrote:
Would you know how I can determine which hyperlink was selected?
I have multiple hyperlinks on a worksheet all jumping to the same
destination worksheet, but each one should be passing different parameters
to the subroutine that does the copy. Thanks.
"Gary''s Student" wrote:
Say we have a hyperlink on Sheet1 that jumps to Sheet2. Say we want to run
code that will copy A1 thru A3 from Sheet1 to Sheet2 cell B9 when the jump is
made. Put the following event macro in the worksheet code area of Sheet1:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
Sheets("Sheet1").Range("A1:A3").Copy Sheets("Sheet2").Range("B9")
End Sub
Because it is worksheet code, it is very easy to install and use:
1. right-click the tab name near the bottom of the window
2. select View Code - this brings up a VBE window
3. paste the stuff in and close the VBE window
If you save the workbook, the macro will be saved with it.
To remove the macro:
1. bring up the VBE windows as above
2. clear the code out
3. close the VBE window
To learn more about macros in general, see:
http://www.mvps.org/dmcritchie/excel/getstarted.htm
To learn more about Event Macros (worksheet code), see:
http://www.mvps.org/dmcritchie/excel/event.htm
--
Gary''s Student - gsnu200903
"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