Need Help with Hyperlink

gruhnelliot

New Member
Joined
Jun 4, 2013
Messages
14
I want to hyperlink two numerical lists on different worksheets. Is this possible?

For example, each person in this test worksheet is assigned a number (18-01, 18-02, etc.)

WORKSHEET # 1
Customer #
FirstLastEMAIL
18-01
Ted
Mosby
18-02ChrisSmith
18-03TonyAdams
18-04

<tbody>
</tbody>


Is there a way to link the customer numbers in worksheet# 1 to the corresponding numbers in worksheet # 2?

WORKSHEET # 2
Customer #JanFebMarApril
18-0150020100
18-0225405050
18-030000
18-040000

<tbody>
</tbody>

 

Excel Facts

What is =ROMAN(40) in Excel?
The Roman numeral for 40 is XL. Bill "MrExcel" Jelen's 40th book was called MrExcel XL.
Assuming you want each cell in sheet1 column A linked to the same cell in Sheet2 if there is some value in sheet1 column A

And by link you mean when you click on Sheet1 Range("A3") you will be taken to Sheet2 Range("A3")

Try this:

If this is not what you want please explain again.

Code:
Sub AddHyperLinks()
'Modified  3/16/2019  8:13:34 PM  EDT
Dim c As Range
With Sheets("Sheet1")
    For Each c In .Range("A2:A" & .Range("A" & .Rows.Count).End(xlUp).Row)
        .Hyperlinks.Add Anchor:=c, Address:="", SubAddress:="'" & "Sheet2" & "'!" & c.Address
    Next c
End With
End Sub

Run this script to add the links. Then just click on the cell in Sheet1 column A
 
Upvote 0
If the customer numbers on sheet2 are in a different row than the customer numbers on sheet1, then try the following code.
Change the data in red for your information.

Code:
Sub New_Hyperlink()
    Dim c As Range, r As Range
    Dim sh1 As Worksheet, sh2 As Worksheet
    
    Set sh1 = Sheets("[COLOR=#ff0000]Sheet1[/COLOR]")
    Set sh2 = Sheets("[COLOR=#ff0000]Sheet2[/COLOR]")
    For Each c In sh1.Range("A2", sh1.Range("A" & Rows.Count).End(xlUp))
        Set r = sh2.Range("A:A").Find(c.Value, LookIn:=xlValues, lookat:=xlWhole)
        If Not r Is Nothing Then
            sh1.Hyperlinks.Add Anchor:=c, Address:="", SubAddress:="'" & sh2.Name & "'!" & r.Address
        End If
    Next
End Sub
 
Upvote 0
My Answer Is This, your script did not work. The following error message appeared:

Run-time error '9':
Subscript out of range

I will try to re word my question.

To preface my question, the first worksheet is named CI Master List. The second worksheet is named 2019 CI Pay Summary.

In "CI Master List", row 1 are title holders. Column A is labeled "CI #". (as pictured below)

CI #
FirstLastEMAIL
18-01TedMosby
18-02ChrisSmith
18-03TonyAdams
18-04

<tbody>
</tbody>



In "2019 Pay Summary", row 1 are title holders. Column A is labeled CI #. (as pictured below).

CI #JanFebMarApril
18-0150020100
18-0225405050
18-030000
18-040000


<tbody>
</tbody>


My goal is to click on cell A2 (18-01) in "CI Master List" and be taken to cell A2 (18-01) in "2019 Pay Summary".

I know how to hyperlink each cell individually, but Column A has hundreds of rows so I was looking for a shortcut.
 
Upvote 0
My script used the sheet names "Sheet1" and "Sheet2"

Did you try modifying these sheet named to see if things worked?

And in Sheet named "Sheet1" you need to have values in column A

See in your original post you posted this:
WORKSHEET # 1

You did not give exact sheet name. So I assumed the sheet name would be Sheet1
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,695
Messages
6,126,263
Members
449,307
Latest member
Andile

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top