Forum Discussion
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
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:
- In the cell where you want to create the hyperlink, right-click and select “Hyperlink” from the context menu.
- In the “Insert Hyperlink” dialog box, select “Place in This Document” from the “Link to” options on the left.
- In the “Type the cell reference” field, enter the cell reference for the cell you want to link to (e.g., A1).
- In the “Or select a place in this document” list, select the name of the tab you want to link to.
- 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!
- NikolinoDEGold Contributor
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:
- In the cell where you want to create the hyperlink, right-click and select “Hyperlink” from the context menu.
- In the “Insert Hyperlink” dialog box, select “Place in This Document” from the “Link to” options on the left.
- In the “Type the cell reference” field, enter the cell reference for the cell you want to link to (e.g., A1).
- In the “Or select a place in this document” list, select the name of the tab you want to link to.
- 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!
- YoshiAehriCopper ContributorThank you for your response, this works great 🙂