+ Reply to Thread
Results 1 to 10 of 10

VBA to write hyperlinks to multiple worksheets

Hybrid View

  1. #1
    Registered User
    Join Date
    04-03-2014
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    9

    VBA to write hyperlinks to multiple worksheets

    Dear Forum Members,

    I am looking for the VBA code to write hyperlinks to multiple worksheets in a Excel 2010 workbook. The hyperlink must be placed in cell H1 of each worksheet. These hyperlinks must all link back to a "dashboard" worksheet. Thanks

  2. #2
    Registered User
    Join Date
    03-28-2014
    Location
    Hertford, England
    MS-Off Ver
    Excel 2010,2013
    Posts
    38

    Re: VBA to write hyperlinks to multiple worksheets

    Something like this?

    Sub AddHyperlink()
        Dim s As Worksheet
        For Each s In ActiveWorkbook.Sheets
            If s.Name <> "Dashboard" Then
                s.Range("H1").Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:="Dashboard!A1", TextToDisplay:="Dashboard"
            End If
        Next s
    End Sub

  3. #3
    Registered User
    Join Date
    03-28-2014
    Location
    Hertford, England
    MS-Off Ver
    Excel 2010,2013
    Posts
    38

    Re: VBA to write hyperlinks to multiple worksheets

    Actually more like this.

    Sub AddHyperlink()
        Dim s As Worksheet
        
        Application.ScreenUpdating = False
        
        For Each s In ActiveWorkbook.Sheets
            If s.Name <> "Dashboard" Then
                s.Activate
                s.Range("H1").Select
                s.Hyperlinks.Add Anchor:=Selection, Address:="", SubAddress:="Dashboard!A1", TextToDisplay:="Dashboard"
            End If
        Next s
        
        Application.ScreenUpdating = True
    End Sub

  4. #4
    Registered User
    Join Date
    04-03-2014
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA to write hyperlinks to multiple worksheets

    Dear foundy,

    No doubt this was very easy for you, so perhaps my gratitude will seem affected, but I would be remiss if I didn't tell you that this 'little' piece of code is fantastic! Thank you very much indeed!

  5. #5
    Registered User
    Join Date
    04-03-2014
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA to write hyperlinks to multiple worksheets

    Dear Foundy,

    I'm curious about why you disable screen updating for the loop. Does this make the makro faster?

  6. #6
    Registered User
    Join Date
    03-28-2014
    Location
    Hertford, England
    MS-Off Ver
    Excel 2010,2013
    Posts
    38

    Re: VBA to write hyperlinks to multiple worksheets

    Glad to help

  7. #7
    Registered User
    Join Date
    03-28-2014
    Location
    Hertford, England
    MS-Off Ver
    Excel 2010,2013
    Posts
    38

    Re: VBA to write hyperlinks to multiple worksheets

    Hi,

    Yes it speeds up the macro, it also stops the screen flicking from sheet to sheet as it adds the hyperlinks.

  8. #8
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA to write hyperlinks to multiple worksheets

    Hello dover.jackiek,

    I had this sample Workbook I wanted to send you yesterday, but we had to content with a power outage for a couple of hours.

    foundy offered you some great assistance, but for what it may be worth to you, feel free to have a look at the attached sample.

    Instead of referring to a "Dasboard" Sheet, the Code uses "Sheet1". Hyperlinks are created in H3 of each other Sheet instead if H1. You may change all these differences to suit.

    If our contributions take care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED.

    Also, since you are relatively new to the forum, I would like to inform you that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which you have been helped. This adds to the reputation of the person who has taken the time to help you.

    Thanks.
    Attached Files Attached Files
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  9. #9
    Registered User
    Join Date
    04-03-2014
    Location
    Johannesburg, South Africa
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: VBA to write hyperlinks to multiple worksheets

    Dear Winon,

    Thanks for the additional spreadsheet and the advice. There is nothing I would like more than to perform the tasks that you suggested to express my gratitude but there are a few problems:

    1) When I click on the login to see the answer to my question I get taken to a set of pages listing hundreds of posts and the post I am looking for is simply not there. Getting back to the post is a mission, to say the least, which was the problem I originally complained about.
    2) I cannot find any "Menu" item, nor any star icon of any nature or description.

    If you can show me the shortcut keys to use the forum I will certainly do so - but at the moment I am getting nowhere. Once again, thank you very much for the additional spreadsheet.

  10. #10
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: VBA to write hyperlinks to multiple worksheets

    Hello dover.jackiek,

    Thank you for the feedback.

    You are welcome.

    Getting back to the post is a mission, to say the least,...
    Just click on the link as it appears in your email inbox, and that will take you to your post in the Forum.

    As for the remaining issues, I see that you were smart enough to sort it out yourself!

    Thank you for adding to my Reputation, much appreciated.

    Regards.

+ 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. Find Hyperlinks, Copy Hyperlinks to alternative sheet, print all hyperlinks
    By matrixpom in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-13-2013, 05:13 PM
  2. Replies: 1
    Last Post: 12-05-2010, 04:39 AM
  3. hyperlinks to other worksheets
    By wildsheep in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-27-2007, 05:24 PM
  4. Hyperlinks within worksheets
    By Rick Wilson in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 03-27-2006, 08:35 AM
  5. select lines from multiple worksheets and write to new worksheet
    By rem in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 09-15-2005, 11:05 AM

Tags for this Thread

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