+ Reply to Thread
Results 1 to 6 of 6

Assign a macro to a hyperlink

  1. #1
    Forum Contributor
    Join Date
    09-08-2005
    Location
    UK
    MS-Off Ver
    2010
    Posts
    107

    Assign a macro to a hyperlink

    I found this whilst trawling the web and I was wondering if there was some way to modify the macro (specifically the 'Select Case Target.Address' >
    'Case “$A$1″' area) to run through many rows without having to create a seperate Case per row (i.e. having 'i' as the number of rows and creating 'Case “$A$i″).

    I would be grateful for any thoughts on this matter

    Cheers.

    "Independent of the hyperlink, put a SelectionChange event in the worksheet code module. To do this, right click the sheet tab, and select View Code. In the code module that pops up, select Worksheet from the top left dropdown, which puts the following procedure into the code module:"
    Please Login or Register  to view this content.

  2. #2
    Tom Ogilvy
    Guest

    RE: Assign a macro to a hyperlink

    You question is not clear, but if you want to do something to a cell on the
    row selected:

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)

    ' just to demonstrate how you could work with
    ' a cell in the same row as the cell selected
    Msgbox cells(target.row,"F").address

    End Sub

    --
    Regards,
    Tom Ogilvy

    "Daminc" wrote:

    >
    > I found this whilst trawling the web and I was wondering if there was
    > some way to modify the macro (specifically the 'Select Case
    > Target.Address' >
    > 'Case β€œ$A$1β€³' area) to run through many rows without having to
    > create a seperate Case per row (i.e. having 'i' as the number of rows
    > and creating 'Case β€œ$A$iβ€³).
    >
    > I would be grateful for any thoughts on this matter
    >
    > Cheers.
    >
    > > -"Independent of the hyperlink, put a SelectionChange event in the
    > > worksheet code module. To do this, right click the sheet tab, and
    > > select View Code. In the code module that pops up, select Worksheet
    > > from the top left dropdown, which puts the following procedure into the
    > > code module:"-

    >
    >
    > Code:
    > --------------------
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > End Sub
    > You then adjust what’s between the Sub and End Sub to get what you want:
    > Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    > Select Case Target.Address
    > Case β€œ$A$1β€³
    > β€˜ carry out action for Cell A1
    > Case β€œ$A$2β€³
    > β€˜ carry out action for Cell A2
    > β€˜ etc.
    > End Select
    > End Sub
    > --------------------
    >
    >
    > --
    > Daminc
    > ------------------------------------------------------------------------
    > Daminc's Profile: http://www.excelforum.com/member.php...o&userid=27074
    > View this thread: http://www.excelforum.com/showthread...hreadid=537207
    >
    >


  3. #3
    Forum Contributor
    Join Date
    09-08-2005
    Location
    UK
    MS-Off Ver
    2010
    Posts
    107
    Cheers for your reply Tom.

    I'm away until Tuesday and I'm going to take a closer look at this procedure them.

  4. #4
    Forum Contributor
    Join Date
    09-08-2005
    Location
    UK
    MS-Off Ver
    2010
    Posts
    107
    Hi Tom, back again

    I've tried that macro you posted and I see where you're coming from.

    To make my original post a little clearer:

    I'm planning to create a hyperlink to a name on a worksheet that, when clicked, will bring up contact details or a graph dipiciting recorded statistics etc depending which will be most required by the person how will use this application.

  5. #5
    Forum Contributor
    Join Date
    09-08-2005
    Location
    UK
    MS-Off Ver
    2010
    Posts
    107
    Please Login or Register  to view this content.
    Could you clarify this bit of code for me please. I have very little information on using 'Intersect'.

    Cheers

    p.s. just to put my last request into context I was looking at 'Worksheet Object Events' in the Excel Help file whilst researching about 'SelectionChange'.

    I was going to experiment with 'Set targetcell = Cells(Target.Row, Target.Column).Address' and then if targetcell was within a certain range (such as A:A) then activate another macro else do nothing.

    Do you think this is sound thinking or am I just going mad :D
    Last edited by Daminc; 05-02-2006 at 04:24 AM.

  6. #6
    Forum Contributor
    Join Date
    09-08-2005
    Location
    UK
    MS-Off Ver
    2010
    Posts
    107
    I've got this little bit of code working:
    Please Login or Register  to view this content.
    I know it's really simple but I think I can now modify it to display calculations derived from other sheets.

    Thanks Tom for showing me a way forward

    p.s. a bit of experimenting showed that I didn't need the 'numRows'.
    Last edited by Daminc; 05-02-2006 at 09:03 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1