Create a hyperlink to workbook sheets on Sheet 1 and exclude certain sheets

sofas

Well-known Member
Joined
Sep 11, 2022
Messages
559
Office Version
  1. 2021
  2. 2019
Platform
  1. Windows
VBA Code:
Sub test()
  



Dim i As Integer

    i = 4

    For Each sh In ThisWorkbook.Worksheets
        ActiveWorkbook.Sheets("Sheet1").Hyperlinks.Add _
        Anchor:=ActiveWorkbook.Sheets("Sheet1").Cells(i, 1), _
        Address:="", _
        SubAddress:="'" & sh.Name & "'!A1", _
        TextToDisplay:=sh.Name
 sh.Hyperlinks.Add Anchor:=sh.Range("E5"), Address:="", SubAddress:="Sheet1" & "!A1", TextToDisplay:="Back to Sheet1"

        i = i + 1
  
      Next sh

Application.ScreenUpdating = False

End Sub
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Hello. I want to create a hyperlink to the pages of the workbook on Sheet 1 and exclude certain sheets from the file, such as Sheet 5 and Sheet 12, while placing a link to return to the main page, without putting it in the main page, of course.
 
Upvote 0
So what is on Sheet1 and where on Sheet1?
thank you for your interest. Sheet 1 is the main one. I want to put links to all the workbook sheets in column A
While ignoring certain sheets I have. For example, sheet 2 and sheet 12. Place a link to refer to Sheet 1 in all Sheets and ignore Sheets 2 and 12
 
Upvote 0
So Column A, starting at A1, has all the sheet names except "Sheet2" and "Sheet12" or it has these names also but they are not hyperlinked?
 
Upvote 0
So Column A, starting at A1, has all the sheet names except "Sheet2" and "Sheet12" or it has these names also but they are not hyperlinked?
'I was able to install this code. Perhaps there are better ways, but it works well and does what is required


VBA Code:
Sub test()
Dim i As Integer
i = 2
For Each sh In ThisWorkbook.Worksheets
Select Case sh.Name
    Case Is = "Sheet1", "Sheet2", "Sheet12"
            Case Else
Application.ScreenUpdating = False
           
        ActiveWorkbook.Sheets("Sheet1").Hyperlinks.Add _
        Anchor:=ActiveWorkbook.Sheets("Sheet1").Cells(i, 1), _
        Address:="", _
        SubAddress:="'" & sh.Name & "'!A1", _
        TextToDisplay:=sh.Name
sh.Hyperlinks.Add Anchor:=sh.Range("b10"), Address:="", SubAddress:="Sheet1" & "!A1", TextToDisplay:="Reference"

    i = i + 1
    End Select

Next sh
Application.ScreenUpdating = True

End Sub
 
Upvote 0
Solution

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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