J Blizzard
New Member
- Joined
- Dec 23, 2019
- Messages
- 20
- Office Version
- 365
- Platform
- Windows
I am trying to type a positive integer into column A of sheet1 and have excel automatically turn that cell into a hyperlink to take me to Column A, Row [that value] of sheet2. So once I type a number, say "5," into sheet1 column A, any row, I want Excel to search sheet2, Column B for the first instance of the number 5 and return that row number to be used in the hyperlink. The reason I want to search for the first instance of what I type is that sheet2 is mostly empty and each value has multiple instances that are grouped together. Going to the first instance of the value will make sure I land at the top of the grouping.
The code I've been given/found/fiddled with right now isn't working and I only partially know what it all does:
Most of this code comes from a previous thread, which solved the problem of how to link from sheet 2 to sheet 1. If there is a simpler way to do this then I'm all ears! Thanks in advance for any help with this.
The code I've been given/found/fiddled with right now isn't working and I only partially know what it all does:
Code:
Private Sub Worksheet_Change(ByVal Target As Range)
If Not (Intersect(Target, Range("A:A")) Is Nothing) Then
If IsNumeric("+" & Target.Value) Then 'Excel treats null cells as numeric and creates a link for them. +1 == 1, and + is not numeric.
rowno = Target.Row
colno = 1
Application.EnableEvents = False
Dim lRow As Long
lRow = Application.WorksheetFunction.Match(Target.Value, Range("Screenshots!B:B"), 0)
With ActiveSheet
celno = "'Screenshots'!B" & lRow
.Hyperlinks.Add Anchor:=.Range(Cells(rowno, colno), Cells(rowno, colno)), _
Address:="", _
SubAddress:=celno
End With
End If
End If
Application.EnableEvents = True
End Sub
Most of this code comes from a previous thread, which solved the problem of how to link from sheet 2 to sheet 1. If there is a simpler way to do this then I'm all ears! Thanks in advance for any help with this.