+ Reply to Thread
Results 1 to 16 of 16

Screen Scrolling Macro (VBA) freezes

  1. #1
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Screen Scrolling Macro (VBA) freezes

    Office 2010 - MS Excel

    I was provided with the following macro (VBA) to scroll a MS Excel spreadsheet on the screen. The macro is activated by a control button on the screen and on about half the occasions it works - the spreadsheet which is actually a quiz score sheet - scrolls up the screen and then down the screen until I press the Escape key on my keyboard. However, on about half the occasions the spreadsheet freezes with the message "Quiz Score Sheet not responding" and everything is greyed out. The only way to get out of the program is to use the Ctrl-Alt-Del keys.

    The values n, sec and viz are read from a second page (currently set at 20, 2 and 10).

    The problem accurs on both a Vista and Windows 7 computer.

    Is there anything obvious that I can change to make the macro more stable?

    =====================================

    Please Login or Register  to view this content.
    ========================================
    Last edited by kencoburn; 03-18-2012 at 06:10 PM.

  2. #2
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Screen Scrolling Macro (VBA) freezes

    You might try scattering the statement DoEvents throughout the code (particularly in the loop) to see if this helps.
    Martin

  3. #3
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Screen Scrolling Macro (VBA) freezes

    Your post does not comply with Rule 3 of our Forum RULES. Use code tags around code. Posting code without them makes your code hard to read and difficult to be copied for testing. Highlight your code and click the # at the top of your post window. For more information about these and other tags, found here
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  4. #4
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Screen Scrolling Macro (VBA) freezes

    Thanks for the quick response

    mrice - I am not a VBA expert and so would appreciate more explicit help on where to insert the DoEvents statement.

    Richard Buttrey - I highlighted the above script and then tried to locate the # sign you referred to - I could not find it.

  5. #5
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Screen Scrolling Macro (VBA) freezes

    Richard - Reference my last message - I now see the # button, it is in the Advanced section. How do I use this on the script that I have already uploaded?

  6. #6
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Screen Scrolling Macro (VBA) freezes

    You need to have the statement ["CODE"] your code ["/CODE"] without the quotation marks before and after your vba code. This will convert it automatically to the proper html style. If you are going to use the button, then highlight your code and press the vba code button. This should put the CODE /CODE delimiters around your code.

    Good luck and thanks for abiding by the rules.
    Please consider:

    Thanking those who helped you. Click the star icon in the lower left part of the contributor's post and add Reputation.
    Cleaning up when you're done. Mark your thread [SOLVED] if you received your answer.

  7. #7
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Screen Scrolling Macro (VBA) freezes

    Unusually, it doesn't really matter where you insert the statement. DoEvents just pauses the processing in Excel to allow other things happening on your compter to take place an this seems to help prevent freezes. Its often trial and error. I would suggest trying inside your While .. Wend loop in the first instance.

  8. #8
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Screen Scrolling Macro (VBA) freezes

    I have introduced the DoEvents statement in two places in the loop and that appears to have worked - the scrolling of the screen does not freeze. Initially I could not stop the scrolling by pressing the Escape key briefly but then found that if I kept the key pressed a little longer (ie.e did not just tap the key) it stopped the scrolling.

    Many thanks for your help.

    Please Login or Register  to view this content.
    Last edited by kencoburn; 03-19-2012 at 06:58 AM.

  9. #9
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Screen Scrolling Macro (VBA) freezes

    Sorry - I commented on being successful too soon. Whilst the Escape key works on my Windows 7 computer it does not work on my Vista laptop (which is the one I will be using for a Quiz Night). Any help would be appreciated so that I can stop the scrolling of the screen without having to close and restart the program.

  10. #10
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Screen Scrolling Macro (VBA) freezes

    Maybe try putting this at the beginning and end of you code:

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Screen Scrolling Macro (VBA) freezes

    I put the code your suggested at the beginning and end of my macro but that did not change anything. The program works find on a Windows 7 PC (the Escape key exits the scrolling) but not on a Vista laptop. Is there a more reliable way of terminating the program?

  12. #12
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Screen Scrolling Macro (VBA) freezes

    There is another method that I use sometimes especially, especially as a cancel button on userforms. I've stripped it down and added your code. Take a look and let me know if it works. If you are going to copy it to another workbook then take care to also copy the code from the Userform.
    Attached Files Attached Files

  13. #13
    Forum Expert mrice's Avatar
    Join Date
    06-22-2004
    Location
    Surrey, England
    MS-Off Ver
    Excel 2013
    Posts
    4,967

    Re: Screen Scrolling Macro (VBA) freezes

    Control - Break sometimes works if escape doesn't.

  14. #14
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Screen Scrolling Macro (VBA) freezes

    Thanks to you both (mrice and abousetta). The Ctrl-Brk solution worked and so because I only use the Quiz spreadsheet occasionally that is how I will break out of the scrolling screen. I did try the script but had a run time error, probably because I am not knowledgeable enought to understand how to integrate the changes to the script. In any case, many thanks to you both. For the record, in case anyone else has this problem, here is my final script (macro).

    Please Login or Register  to view this content.

  15. #15
    Forum Guru
    Join Date
    03-12-2010
    Location
    Canada
    MS-Off Ver
    2010 and 2013
    Posts
    4,418

    Re: Screen Scrolling Macro (VBA) freezes

    Glad it worked out. If you are satisfied with the responses then mark the thread as solved.

  16. #16
    Forum Contributor
    Join Date
    02-24-2008
    Location
    UK
    MS-Off Ver
    2012 and 2016
    Posts
    123

    Re: Screen Scrolling Macro (VBA) freezes

    How do I mark this as solved - I could not find any way of doing so?

+ 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