Auto hyperlink same cells between them VBA

ToseSenpai

New Member
Joined
Apr 18, 2021
Messages
29
Office Version
  1. 365
Platform
  1. Windows
Hi all,

There is a way to hyperlink same cells between them with a vba macro?
For example, i got 3 sheets with the same numbers in every sheets, there is a way to automatically hyperlink them without do it manually?

I mean that when I click on a cell with the value it takes me directly to the another cell with the same value in the file excel, and so on...

I hope I explained myself!

Thank you all for your help! :)
 

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
Rather than using a hyperlink you can do it by using the doubleclick event. This code takes the value of the cell in column A on sheet 1 then search sheet 2 column A for the value and select that cell on sheet 2. You can obviously put similar code in sheet 2 to take you to sheet3 and in sheet 3 to take you back to sheet 1
Put this code in the worksheet code for sheet1
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
' with thanks to Ron de Bruin for the vba find code
Dim rng As Range
If Target.Column = 1 Then
Findstring = Target.Value
With Sheets("Sheet2").Range("A:A")
Set rng = .Find(What:=Findstring, _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlWhole, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not rng Is Nothing Then
                Application.Goto rng, True
            Else
                MsgBox "Nothing found"
            End If
 End With
 End If
   
End Sub
 
Upvote 0
Rather than using a hyperlink you can do it by using the doubleclick event. This code takes the value of the cell in column A on sheet 1 then search sheet 2 column A for the value and select that cell on sheet 2. You can obviously put similar code in sheet 2 to take you to sheet3 and in sheet 3 to take you back to sheet 1
Put this code in the worksheet code for sheet1
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
' with thanks to Ron de Bruin for the vba find code
Dim rng As Range
If Target.Column = 1 Then
Findstring = Target.Value
With Sheets("Sheet2").Range("A:A")
Set rng = .Find(What:=Findstring, _
                            After:=.Cells(.Cells.Count), _
                            LookIn:=xlValues, _
                            LookAt:=xlWhole, _
                            SearchOrder:=xlByRows, _
                            SearchDirection:=xlNext, _
                            MatchCase:=False)
            If Not rng Is Nothing Then
                Application.Goto rng, True
            Else
                MsgBox "Nothing found"
            End If
 End With
 End If
  
End Sub
Ty fot the solution :)
There is a way for search instead of only sheet 2 in all workbook?
 
Upvote 0
You mean if it is not found on sheet 2 you want to go on to sheet 3 , etc, etc??
 
Upvote 0
try this:
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
' with thanks to Ron de Bruin for the vba find code
Dim rng As Range
If Target.Column = 1 Then
Findstring = Target.Value
For i = 1 To Worksheets.Count
    If Worksheets(i).Name <> ActiveSheet.Name Then
        With Worksheets(i).Range("A:A")
        Set rng = .Find(What:=Findstring, _
                                    After:=.Cells(.Cells.Count), _
                                    LookIn:=xlValues, _
                                    LookAt:=xlWhole, _
                                    SearchOrder:=xlByRows, _
                                    SearchDirection:=xlNext, _
                                    MatchCase:=False)
                    If Not rng Is Nothing Then
                       Application.Goto rng, True
                       Exit For
                    End If
         End With
    End If
Next i
End If
End Sub
 
Upvote 0
Solution
try this:
VBA Code:
Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, Cancel As Boolean)
' with thanks to Ron de Bruin for the vba find code
Dim rng As Range
If Target.Column = 1 Then
Findstring = Target.Value
For i = 1 To Worksheets.Count
    If Worksheets(i).Name <> ActiveSheet.Name Then
        With Worksheets(i).Range("A:A")
        Set rng = .Find(What:=Findstring, _
                                    After:=.Cells(.Cells.Count), _
                                    LookIn:=xlValues, _
                                    LookAt:=xlWhole, _
                                    SearchOrder:=xlByRows, _
                                    SearchDirection:=xlNext, _
                                    MatchCase:=False)
                    If Not rng Is Nothing Then
                       Application.Goto rng, True
                       Exit For
                    End If
         End With
    End If
Next i
End If
End Sub
Ty very much! It works :)
 
Upvote 0

Forum statistics

Threads
1,214,998
Messages
6,122,639
Members
449,093
Latest member
Ahmad123098

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