+ Reply to Thread
Results 1 to 19 of 19

Hyperlink open location

  1. #1
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Hyperlink open location

    How can i get hyperlinks to locations within the same workbook to open with the linked cell at the top of the window instead of the bottom

    I also asked this question on MrExcel because I kind of need https://www.mrexcel.com/forum/excel-...ml#post4829835

  2. #2
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,008

    Re: Hyperlink open location

    .
    .
    Try pasting this macro into each sheet module you are hyperlinking to.

    Please Login or Register  to view this content.

  3. #3
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    An elegant and simple solution. It works perfectly.
    Thanks so much for your help and your expertise.

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,008

    Re: Hyperlink open location

    You are welcome

    You could try pasting the macro in the ThisWorkbook module so it affects all worksheets but allows you to not need pasting in each sheet module.
    Hope that made sense.

    Not certain that would work cuz I haven't tried it here. No hyperlinks to work with.

    Let me know if that works also .. ok ?
    Last edited by Logit; 05-22-2017 at 12:39 PM.

  5. #5
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    Your description was a little misleading.

    Try pasting this macro into each sheet module you are hyperlinking to.

    It sounds like you're saying to paste it into the destination sheets that the hyperlinked cells point to but it actually doesn't work if you do that. It worked when I pasted the code into the source sheets (ie: the sheets that contain the hyperlinked cells) This also accomplishes what you just suggested because pasting the code you provided works for all sheets you have links to within that sheet. So pasting it into my index tab makes all links within this tab to open their respective destinations at the top of the window for all sheets within the workbook so there's no need to paste it into multiple sheets just the one works for all destinations. At least in my situation because all the hyperlinked cells are contained within my index tab.

    A GREAT solution.
    Last edited by SageAdvisor; 05-22-2017 at 12:50 PM.

  6. #6
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    I tried to use your solution in another workbook I have that I've always wanted the same thing to happen but it didn't work quite the same. I use a Combo box in that workbook and your code disables the combo box for some reason. Can you think of why this would happen and possibly a solution that wouldn't disable my combo box.

    Thanks

  7. #7
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,008

    Re: Hyperlink open location

    I don't know why it would affect the Combobox.

    Can you post that workbook for review ?

    Glad to know the macro works when placed in ThisWorkbook. Saves alot of typing / pasting.

  8. #8
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    It actually doesn't work if you paste the code into ThisWorkbook.
    It also doesn't work if you paste the code into the destination sheets.
    It only works if you paste the code into the sheet that contains the cells with the hyperlinks themselves.

    Here's a link to the workbook you requested
    https://drive.google.com/open?id=0B0...G8wWUhQenZtdW8

    The two tabs I tried that have combo boxes in them are the TV Shows Tab and the Mini-Series Tab
    (your code caused both sheets comboboxes to fail)

    You have to click on the UNHIDE button to see the index. Or CTRL + M.
    The comboboxes themselves are designed to do the same thing as your code. Open the destination at the top of the window. Maybe the two scripts are interfering with each other?

    Thanks for your help.
    Last edited by SageAdvisor; 05-22-2017 at 01:36 PM.

  9. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,008

    Re: Hyperlink open location

    Apologies .. misunderstood.

    I have the workbook. Let me look at it and see what can be done.

  10. #10
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,008

    Re: Hyperlink open location

    Which tab is the 'index' tab ?

  11. #11
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    That was in the other workbook. This workbook doesn't have an index tab.
    The sheets I'm trying to use your code in this workbook are the TV Shows Tab and the Mini-Series Tab.
    Those two tabs both have a combobox at the top (Cell C1)
    Just click in the outline of a box in that cell and a dropdown appears.
    If you add your code to the sheet code the combobox will work until you click on one of the links in the index
    (Visible when you click the UNHIDE button (At B1)
    Then your code takes over and the index works the way your code tells it to meaning the links open at the top of the window but the combobox no longer works.

  12. #12
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,008

    Re: Hyperlink open location

    Give this a go and see what you think :
    Attached Files Attached Files

  13. #13
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    I notice when entering the code in the TV Shows tab and the Mini-Series tab it shows up like this

    Option Explicit
    ____________________________________________________________________________________________________
    Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    ActiveWindow.ScrollRow = ActiveCell.Row
    End Sub

    With the Option Explicit included in the previous script.
    Normally the line would appear above the entire new script. That's what's happened with every script I've added to excel from my recollection. Could that be the problem?

    Normally it would appear in the code sheet like this
    ____________________________________________________________________________________________________
    Option Explicit

    Private Sub Worksheet_FollowHyperlink(ByVal Target As Hyperlink)
    ActiveWindow.ScrollRow = ActiveCell.Row
    End Sub

    But the Option Explicit is being included under End Sub with the prior script.
    I don't know if that makes a difference the End Sub should end the prior routine If I'm not mistaken but....

  14. #14
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    I tried the sheet you linked to and The Combobox is completely disabled it doesn't even drop down when you click on it. It's completely dead.
    Also the Hide and unhide buttons no longer work and generate an error message and even your code doesn't work.
    If you click on the links in the index starting from the bottom going up the clicked link opens at the top but if you click on the links going down starting from the first one it only works for the first one you click every one after that under the first one you clicked opens at the bottom of the window.

  15. #15
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    Never mind my last post it works perfectly.
    I opened your updated copy it right from the link into excel without saving a local copy first and that may be the reason it didn't work.
    I saved a copy and tried it on my main PC and it works perfectly.

    Turns out it was a trust issue I opened it from a location that I hadn't trusted in the excel trust settings.

    Anyway it works and thank you so much you clever fellow.

  16. #16
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    Do you know if I could enter this code in my personal.xlsb to use it in every sheet that has links
    If you ask me links should always open at the top of the window instead of the bottom.
    That should be the default but since it's not I would like to make it so.

    Would that work?

  17. #17
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,008

    Re: Hyperlink open location

    I placed my macro in the ThisWorkbook module and disabled the same macro in the two worksheet level modules.
    It seems to work 100% from the drop down boxes in both Sheets .. however, clicking on some of the hyperlinks that
    are listed in the sheet rows .. some of them won't appear at the top of the sheet as desired.

    So I presume you'll always need to place the macro in each sheet level module.

    Using the same macro on other projects should not be an issue as the code is generic.

  18. #18
    Registered User
    Join Date
    05-10-2014
    MS-Off Ver
    Excel 2007
    Posts
    57

    Re: Hyperlink open location

    The dropdowns are designed to open at the top of the window on their own.

    You've found as I did the script doesn't work at all if it's in the ThisWorkbook module the fact that some links open at the top and the rest at the bottom is the normal behavior of excel.
    If you click on the links in the index starting from the bottom going up the clicked link opens at the top but if you click on the links going down starting from the first one it only works for the first one you click every one after that opens at the bottom of the window.

    I tried putting your code in personal.xlsb but it doesn't function at all. I don't know why it doesn't work the whole purpose of the personal book is so scripts and macros work across workbooks but whatevs. So I'll do it old school it's not as convenient but I'm thrilled to have this script which I know I'll use many more times in the future.

    I've already put it in a bunch of my other workbooks so thank you so much it's so much better opening at the top it makes so much sense I have no idea why it's not the default behavior of excel it really should be.

    Thank you so much for your help.
    Have a fantastic week.

  19. #19
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,008

    Re: Hyperlink open location

    You are welcome.

+ 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. Hyperlink Look In default Location
    By Phillip Walters in forum Excel General
    Replies: 1
    Last Post: 06-24-2016, 04:53 PM
  2. Open hyperlink (photo) in a specific spreadsheet location and specific size
    By bigtex in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-08-2015, 02:45 PM
  3. [SOLVED] [Help]macro to open file browser, to select a location, and save the location to a cell
    By zhuleijia in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-06-2013, 09:56 AM
  4. Replies: 1
    Last Post: 02-23-2013, 05:18 AM
  5. Replies: 2
    Last Post: 01-19-2013, 09:13 AM
  6. [SOLVED] Location hyperlink
    By 1Monkey in forum Excel General
    Replies: 1
    Last Post: 10-11-2012, 03:09 AM
  7. Collecting the location of a hyperlink
    By wilro85 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 12-27-2006, 08:03 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