+ Reply to Thread
Results 1 to 10 of 10

Scroll rows in a wb that displays a scoreboard

  1. #1
    Registered User
    Join Date
    03-31-2013
    Location
    Geraldine NZ
    MS-Off Ver
    Excel 2003, 2010
    Posts
    6

    Scroll rows in a wb that displays a scoreboard

    I have workbook that displays a scoreboard generated by values form another workbook. The number of scores (rows) is greater than the visibble screen area, so I need to scroll the worksheet slowly to allow viewers to see the scores. I need this to happen without freezing excel as I need to be updating scores in the source workbook on the fly, so Application.Wait will not do. Any suggestions please?

  2. #2
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Scroll rows in a wb that displays a scoreboard

    Use Application.OnTime to call subroutine that will scroll
    If you are pleased with a member's answer then use the Star icon to rate it.

  3. #3
    Registered User
    Join Date
    03-31-2013
    Location
    Geraldine NZ
    MS-Off Ver
    Excel 2003, 2010
    Posts
    6

    Re: Scroll rows in a wb that displays a scoreboard

    Thanks buran, I have used Application.OnTime to call a procedure "Scroll_Rows", and it works. But the start time for Application.OnTime will not update, so all the rows are scrolled instantly instead of one row at a time after a delay - which I have set as "UpdateInterval2". See my code below -

    Please Login or Register  to view this content.
    How do I get RunTime2 to update for each time the "Scroll_Row" procedure is called?

    Thanks.
    Last edited by Clay Shooter; 04-18-2013 at 04:50 AM.

  4. #4
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Scroll rows in a wb that displays a scoreboard

    Please, use Code tags around your code as per the forum rules.

  5. #5
    Registered User
    Join Date
    03-31-2013
    Location
    Geraldine NZ
    MS-Off Ver
    Excel 2003, 2010
    Posts
    6

    Re: Scroll rows in a wb that displays a scoreboard

    Sorry, thought I did that - see edited post above.
    Thanks

  6. #6
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Scroll rows in a wb that displays a scoreboard

    Hi Clay, thanks

    the problem with your code is in that line

    Please Login or Register  to view this content.
    The entire loop takes less than a second, so you set all the calls to "Scroll_Row" sub within 1 second.
    Change your code like this

    Please Login or Register  to view this content.
    Note that once you start it, you cannot disable the scroll unless you store each RunTime somewhere and set schedule = False for each scheduled run.

  7. #7
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Scroll rows in a wb that displays a scoreboard

    Also note that I pass the row number as argument to Scroll_Row. Change that if you have different Scroll_Row sub

  8. #8
    Registered User
    Join Date
    03-31-2013
    Location
    Geraldine NZ
    MS-Off Ver
    Excel 2003, 2010
    Posts
    6

    Re: Scroll rows in a wb that displays a scoreboard

    Thanks Buran, sorry for he 12 hour delay in posting responses, but I am that many time zones away from you in Europe.
    I see exactly how you have modified my RunTime2 variable - and it works just like I wanted. I also see how you have created the row variable into my Scroll_Row sub so that it changes its name each time it is called. This works too, but I can't see how you set the value of lngScrollRow.
    The macro seems to stop running when it has reached the i = Lr value, but I understand that the macro might be continuing to run because it has not been cancelled.
    I have written some code (below) that I think should cancel the Application.OnTime but it returns the Method 'OnTime' of object _Application' failed error. It does this even if I put the code in the Scroll_Row macro.
    Does the problem have something to do with how the lngScrollRow variable is defined?

    Please Login or Register  to view this content.
    Your help is appreciated.

  9. #9
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Scroll rows in a wb that displays a scoreboard

    Hi.

    When you use OnTime method you schedule number of calls to Scroll_row sub. the main sub Display_Scores will finish in a second or two (depends how many rows you have, i.e. Lr-11 number of rows). When it finish you have scheduled Lr-11 times runs of Scroll_Row macro, each of them separated in time by UpdateInterval2 seconds. So to cancel, you should cancel each individual scheduled run with the same statement that you used to schedule it and only last argument set to False. That's why I made the note.

    As an alternative you can use recursion and make Scroll_Row schedule the next run. This way at any point of time you will have only one scheduled run. here is sample code:

    Please Login or Register  to view this content.
    I would recommend this approach. You can call off next run using the statement

    Please Login or Register  to view this content.
    Last edited by buran; 04-19-2013 at 09:03 AM. Reason: Correct the statement that cancel the run

  10. #10
    Forum Expert
    Join Date
    06-25-2009
    Location
    Sofia, Bulgaria, EU
    MS-Off Ver
    Excel 2003-2013
    Posts
    1,290

    Re: Scroll rows in a wb that displays a scoreboard

    I just didn't reply to your question about how I set lngScrollRow variable. It's argument to the sub and I pass it here

    Please Login or Register  to view this content.
    Note the i and also the single quotes.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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