+ Reply to Thread
Results 1 to 5 of 5

VBA to create a link to every sheet except one

Hybrid View

  1. #1
    Registered User
    Join Date
    01-24-2017
    Location
    home
    MS-Off Ver
    MS Office 2016
    Posts
    46

    VBA to create a link to every sheet except one

    I have a file that has multiple worksheets. The first sheet is a summary sheet pulling information from every other sheet. The first column lists the names of every sheet after the first one. I am trying to have all of those names have links to them, but the problem is my code is adding a link to the current sheet I am on. How do I get it to skip the first sheet aka "Summary-Sheet"


    Dim Ws As Worksheet
    
    Worksheets("Summary-Sheet").Select
    Range("A2").Select
    
    For Each Ws In ActiveWorkbook.Worksheets
    ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:="", SubAddress:="" & Ws.Name & "!A2" & "", ScreenTip:="", TextToDisplay:=Ws.Name
    ActiveCell.Offset(1, 0).Select
    
    Next Ws
    Last edited by kasermap; 02-11-2020 at 10:52 AM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2502
    Posts
    26,991

    Re: VBA to create a link to every sheet except one

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    (Note: this change is not optional. No help to be offered until this moderation request has been fulfilled.)
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: VBA to create a link to every sheet except one

    What about:

    Dim Ws As Worksheet
    For Each Ws In ActiveWorkbook.Worksheets
     If Ws.Name <> "Summary-Sheet" Then
        ActiveCell.Hyperlinks.Add Anchor:=ActiveCell, Address:="", SubAddress:="" & Ws.Name & "!A2" & "", ScreenTip:="", TextToDisplay:=Ws.Name
        ActiveCell.Offset(1, 0).Select
     End If
    Next Ws
    Happy with my answer * Add Reputation.
    If You are happy with solution, please use Thread tools and mark thread as SOLVED.

  4. #4
    Registered User
    Join Date
    01-24-2017
    Location
    home
    MS-Off Ver
    MS Office 2016
    Posts
    46

    Re: VBA to create a link to every sheet except one

    It put the hyperlink starting in cell A1 instead of A2. I am also getting 'reference not valid' when I click a link.

  5. #5
    Forum Expert KOKOSEK's Avatar
    Join Date
    08-03-2018
    Location
    Pole in Yorkshire, UK
    MS-Off Ver
    365/2013
    Posts
    2,765

    Re: VBA to create a link to every sheet except one

    Macro works. I don't know how you run it.
    Attached sample file.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Create a link from a master sheet
    By EirlysA in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 06-22-2017, 08:48 AM
  2. Create and rename sheet in vba then link to it
    By J鏮 Ingi in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-25-2014, 05:20 PM
  3. [SOLVED] Create a link to non existing sheet
    By Jele007 in forum Excel General
    Replies: 5
    Last Post: 07-16-2014, 08:08 PM
  4. Macro to Create and link a Note Sheet
    By Czarified in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-24-2014, 10:21 AM
  5. Create Link between column from two sheet
    By abraham30 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-27-2013, 04:38 PM
  6. Create a link to sheet on register
    By jsmity in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-20-2011, 03:56 AM
  7. [SOLVED] How can I create a link to a specific sheet from external web page
    By John D in forum Excel General
    Replies: 1
    Last Post: 02-22-2005, 05:06 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1