Thanks. I'm not sure how to handle this line from the other block of code--I get an error when using the quotation marks (assuming it sees them as the end of the statement rather than declaration of the data sheet):
If Not f Is Nothing Then Sheets("Data Sheet 4").Hyperlinks.Add c, "", "Sheets("Data Sheet 4")!" & f.Address
Please do not quote (see the forum rules).
With my example you must be able to do this yourself.
It's the best way to get a 'feeling' for VBA.
Use in the second block an approach analogous to mine:
sub snb_4() On Error Resume Next for each cl in columns(2).specialcells(2) Hyperlinks.Add cl, "", "#'Data Sheet 4'!" & sheets("Data Sheet 4").Columns(5).Find(cl.Value, , xlValues, xlWhole).Address next End Sub
Last edited by snb; 11-01-2011 at 11:19 AM.
Thanks for everyone's help, I finally got it working. Here is the final code I am using:
Sub HyperlinkSheet4ColAToSheet2ColF() Dim c As Range, f As Range Application.EnableEvents = False Sheets("Data Sheet 4").Range("A2", Sheets("Data Sheet 4").Range("A" & Rows.Count).End(xlUp)).Hyperlinks.Delete For Each c In Sheets("Data Sheet 4").Range("A2", Sheets("Data Sheet 4").Range("A" & Rows.Count).End(xlUp)) Set f = Sheets("Data Sheet 2").Range("F2", Sheets("Data Sheet 2").Range("F" & Rows.Count).End(xlUp)).Find(c.Value) If Not f Is Nothing Then Sheets("Data Sheet 4").Hyperlinks.Add c, "", "'Data Sheet 2'!" & f.Address Next c Application.EnableEvents = True End Sub
and
Private Sub Worksheet_Change(ByVal Target As Range) If Target.Cells.Count > 1 Or Target.Column <> 1 Then Exit Sub On Error Resume Next Target.Hyperlinks.Delete Hyperlinks.Add Target, "", "'Data Sheet 2'!" & Sheets("Data Sheet 2").Columns(5).Find(Target.Value, , xlValues, xlWhole).Address(, , , True) End Sub
Thanks again!
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks