+ Reply to Thread
Results 1 to 10 of 10

When executing macro via hyperlink, macro doesn't re-scroll window back to A1

  1. #1
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    Hi guys. I need slight help with one of my macros. I'm using following code on sheet called "analyse" to execute macro via hyperlink
    Please Login or Register  to view this content.
    This code is placed within the correct module of course (under analyze)


    Now when clicking E7 on sheet "analyze" it triggers macro "hyperlink_backlog_monday" which essentially copies information from one sheet to another, filters in some unwanted rows and deletes them. As a part of the code in "hyperlink_backlog_monday" I have following line
    Please Login or Register  to view this content.
    This line simply scrolls window back to A1. Its a good feature to have. Otherwise when I go back and forth between the sheets and re run some macros, it then remembers the last window placement. This causes me to scroll back to A1 manually with a mouse. This gets annoying really fast.

    Anyway, when I execute"hyperlink_backlog_monday" in normal way it performs all actions beautifully and line Application.Goto Reference:=Range("a1"), Scroll:=True does its job.
    But as soon as macro "hyperlink_backlog_monday" is executed via clicking E7 on sheet "analyze" it performs everything within the macro except this scrolling part. After the macro run, the window scroll bars are where the were last time when used.

    Can anyone help me to tackle this problem. I would be very grateful.


    Cheers
    Rain

    EDIT: See attached xls on post 3
    Last edited by rain4u; 05-15-2011 at 02:31 PM.

  2. #2
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    Try replacing this:

    Please Login or Register  to view this content.
    with this code:

    Please Login or Register  to view this content.

  3. #3
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Re: When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    Thank you for the help. He he. I also tried that. Unfortunately it then performs re scroll on sheet "analyze" where the the macro is executed instead performing it on the sheet where the copy-paste, and removing some lines happens.

    Any other suggestions?


    PS! I have now attached demo xls. Click E7 on sheet analyse. On sheet Hyperlink I have purposely left the scroll bars to random place. Note if you run macro "hyperlink_backlog_monday" manually on module 11 you will achieve the result required.


    Cheers
    Rain
    Attached Files Attached Files
    Last edited by rain4u; 05-15-2011 at 01:41 PM. Reason: updated the spreadsheet

  4. #4
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    Please Login or Register  to view this content.

    Or

    Please Login or Register  to view this content.
    If you are allowed post a workbook if neither of these works.
    Last edited by 111StepsAhead; 05-15-2011 at 12:34 PM.

  5. #5
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    This code worked for me. Replaced the code on your Sheet4 (Analyze)

    Please Login or Register  to view this content.

  6. #6
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Re: When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    Thanks. Works like a charm. One more question though. What if I have more lines on the code like below
    Please Login or Register  to view this content.

    Would it be possible to place that code somewhere in the end, or there is no way around and the code needs to be between ever "if" statement like below:
    Please Login or Register  to view this content.
    Thanx for helping me
    Rain

  7. #7
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    This is a first effort. I don't have all the sheets in mine which I am guessing each name will be a different sheet.

    Please Login or Register  to view this content.

  8. #8
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Re: When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    Oh sorry. Demo xls was just shortened version of the actual file to make it a lot smaller. Sheets will always remain the same i.e. Master YM26, Analyze and Hyperlink. Macros just filter in and out different information and delete unnecessary rows.

    With your latest offered code something is messed up. Now regardless where you click on spreadsheet (even if its something random as cell T311) it runs a macro that deletes all rows from row 2 downwards. I updated the spreadsheet posted on post number 3 with your the latest code. Can you help me bit further and look into it once more? I think we are almost there.



    Cheers
    Rain

  9. #9
    Forum Contributor
    Join Date
    04-11-2011
    Location
    Columbus, Ohio
    MS-Off Ver
    Excel 2007
    Posts
    325

    Re: When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    I don't know how well this would work. I get an error that the names are macros but can't be run because they are disabled when in fact all macros in my excel sheet are enabled. Run this code and tell me what happens,.

    Please Login or Register  to view this content.

  10. #10
    Forum Contributor
    Join Date
    01-29-2011
    Location
    Bristol, England
    MS-Off Ver
    Excel 2003
    Posts
    471

    Re: When executing macro via hyperlink, macro doesn't re-scroll window back to A1

    Awesome. Looks to be working as I imagined. Thank you very much. Finally no more scrolling with mouse


    Cheers
    Rain

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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