Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to return the row number where hyperlink lives?

Status
Not open for further replies.

realtree

Technical User
Aug 5, 2003
53
0
0
CA
This probly sounds really simple, but I'm stumped. I have a table with a hyperlink on the end of each row. I need the form's function to be dependant on which row the link came from. The hyperlink points to a dummy cell, because I just want it to load a form. Target.Range.Row is the right property as far as I can tell, but all it returns is '2' for the second row, and '3' for all subsequent rows.
 
To clarify, Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink) is the event that triggers the code.
 
Hi trefrog,

I wonder if the problem is that the dummy cell is on row 2 for the 2nd row, and row 3 for the rest?

If your hyperlinks pointed to their own cells, you could use:
Target.Hyperlinks(1).SubAddress
to find out which cell triggered the code.

Cheers
 
Actually the dummy cell is A1, and I have row 1 as a frozen pane. It works out perfectly, cuz it's a really tall sheet and when it tries to target A1, it's locked - plus it's always visible so it doesn't ever remove focus or bring the clicked link out of frame. The reason they all point to A1 is because all I had to do is make one, and then auto fill the rest. The autofill doesn't increment the cell. I don't wanna have to edit 1230 hyperlinks.

I need to store the row number as an int/long, so .Row would be most convenient.

Here's the code thus far:
Code:
Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    Dim lngRow As Long
    lngRow = Target.Range.Row
    'MsgBox lngRow
    Load formScore
    formScore.Show
    Unload formScore
    Worksheets("Schedule").Range("I1").Activate
End Sub
 
Okay. I fixed the problem on my own. I don't know why the autofill was acting like that before. I deleted the hyperlinks and made a few manual ones, then autofilled the rest. For some reason, the cells 'thought' they were in row 3... which poses another paradox... not worth solving.
mehhhhhh...
 
Glad to hear it - I was striggling to see where your code was going wrong ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top