Forum Discussion

YoshiAehri's avatar
YoshiAehri
Copper Contributor
Apr 14, 2023

Linking back to a tab from search results

Hi,

 

I have a database with searches that move the search results to the "Summary" tab, I was wondering if there is a way for the user to click on one of the results and be taken back to the original tab?

 

Thanks

  • YoshiAehri 

    It is possible to create a hyperlink in Excel that will take the user back to a specific tab when clicked.

    Here’s how you can do it:

    1. In the cell where you want to create the hyperlink, right-click and select “Hyperlink” from the context menu.
    2. In the “Insert Hyperlink” dialog box, select “Place in This Document” from the “Link to” options on the left.
    3. In the “Type the cell reference” field, enter the cell reference for the cell you want to link to (e.g., A1).
    4. In the “Or select a place in this document” list, select the name of the tab you want to link to.
    5. Click “OK” to create the hyperlink.

    Now, when a user clicks on the hyperlink, they will be taken back to the specified tab and cell.

     

    You can use a macro too, to create a hyperlink that takes the user back to a specific tab in Excel.

    Here’s an example of a VBA code that you can use to achieve this:

    Sub CreateHyperlink()
        ' Set the variables for the sheet and cell you want to link to
        Dim targetSheet As String
        Dim targetCell As String
        targetSheet = "Sheet1"
        targetCell = "A1"
    
        ' Set the variables for the location of the hyperlink
        Dim hyperlinkSheet As String
        Dim hyperlinkCell As String
        hyperlinkSheet = "Summary"
        hyperlinkCell = "B2"
    
        ' Create the hyperlink
        Sheets(hyperlinkSheet).Hyperlinks.Add Anchor:=Sheets(hyperlinkSheet).Range(hyperlinkCell), Address:="", SubAddress:= _
            "'" & targetSheet & "'!" & targetCell, TextToDisplay:="Go to " & targetSheet
    End Sub

    This code creates a hyperlink in cell B2 of the “Summary” tab that takes the user back to cell A1 of “Sheet1” when clicked.

    You can customize the code by changing the values of the targetSheet, targetCell, hyperlinkSheet, and hyperlinkCell variables to match your specific needs.

     

    I hope this helps!

  • NikolinoDE's avatar
    NikolinoDE
    Gold Contributor

    YoshiAehri 

    It is possible to create a hyperlink in Excel that will take the user back to a specific tab when clicked.

    Here’s how you can do it:

    1. In the cell where you want to create the hyperlink, right-click and select “Hyperlink” from the context menu.
    2. In the “Insert Hyperlink” dialog box, select “Place in This Document” from the “Link to” options on the left.
    3. In the “Type the cell reference” field, enter the cell reference for the cell you want to link to (e.g., A1).
    4. In the “Or select a place in this document” list, select the name of the tab you want to link to.
    5. Click “OK” to create the hyperlink.

    Now, when a user clicks on the hyperlink, they will be taken back to the specified tab and cell.

     

    You can use a macro too, to create a hyperlink that takes the user back to a specific tab in Excel.

    Here’s an example of a VBA code that you can use to achieve this:

    Sub CreateHyperlink()
        ' Set the variables for the sheet and cell you want to link to
        Dim targetSheet As String
        Dim targetCell As String
        targetSheet = "Sheet1"
        targetCell = "A1"
    
        ' Set the variables for the location of the hyperlink
        Dim hyperlinkSheet As String
        Dim hyperlinkCell As String
        hyperlinkSheet = "Summary"
        hyperlinkCell = "B2"
    
        ' Create the hyperlink
        Sheets(hyperlinkSheet).Hyperlinks.Add Anchor:=Sheets(hyperlinkSheet).Range(hyperlinkCell), Address:="", SubAddress:= _
            "'" & targetSheet & "'!" & targetCell, TextToDisplay:="Go to " & targetSheet
    End Sub

    This code creates a hyperlink in cell B2 of the “Summary” tab that takes the user back to cell A1 of “Sheet1” when clicked.

    You can customize the code by changing the values of the targetSheet, targetCell, hyperlinkSheet, and hyperlinkCell variables to match your specific needs.

     

    I hope this helps!

    • YoshiAehri's avatar
      YoshiAehri
      Copper Contributor
      Thank you for your response, this works great 🙂

Resources