Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Apr 2007
    Location
    Lancashire, United Kingdom
    Posts
    264
    Thanks
    32
    Thanked 5 Times in 5 Posts

    How can I reliably indicate progress through a program to the user?

    In my code, I am reading thousands of lines of data and manipulating it. So the user doesn't think the system has gone to sleep, I have this line

    Code:
     If loopcount Mod 100 = 0 Then Application.StatusBar = " Reading input record " & loopcount ' so we know whats going on
    However, sometimes, it seems to go to sleep and not increment the counter. The program works fine - but the counter goes up to some number (and it can vary) and then just stops.

    Can anyone give me a reliable way to indicate progress?

    regards

    Alan

  2. #2
    3 Star Lounger
    Join Date
    Apr 2007
    Location
    Lancashire, United Kingdom
    Posts
    264
    Thanks
    32
    Thanked 5 Times in 5 Posts
    Oops sorry. I'll look at your code.

    Alan

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts
    Try adding DoEvents. I think sometimes it "misses the opportunity" to change the statusbar, the DoEvents ensures it gets updated

    Code:
    If loopcount Mod 100 = 0 Then
     Application.StatusBar = " Reading input record " & loopcount ' so we know whats going on
     DoEvents 'To ensure StatusBar gets updated
    end if
    Steve

  4. The Following User Says Thank You to sdckapr For This Useful Post:

    alan sh (2014-01-16)

  5. #4
    3 Star Lounger
    Join Date
    Apr 2007
    Location
    Lancashire, United Kingdom
    Posts
    264
    Thanks
    32
    Thanked 5 Times in 5 Posts
    SDC, that will do nicely. Thanks.

    Maudibe, I've had a look and while it's nice, I have no idea what the maximum value of my data will be. It could be 2 lines, it could be 2 million lines. So, a progress bar won't really work.

    I need something that says "Still working OK and got to line number X".

    Alan

  6. #5
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,433
    Thanks
    371
    Thanked 1,456 Times in 1,325 Posts
    Alan,

    Since you posted this in the Excel forum I'll assume you're working on a Workbook. It is easy to figure out the number of lines to process by simply inserting this code into Maud's code:
    Code:
    lLastRow = Cells(rows.Count, "A").end(xlup).row
    
    '*** Where: "A" is the column used to determing last row.
    '***  i.e. a column w/o blank entries.
    Then just substitute lLastRow as the max value. HTH
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  7. The Following User Says Thank You to RetiredGeek For This Useful Post:

    alan sh (2014-01-16)

  8. #6
    3 Star Lounger
    Join Date
    Apr 2007
    Location
    Lancashire, United Kingdom
    Posts
    264
    Thanks
    32
    Thanked 5 Times in 5 Posts
    Nice one. I keep learning new things on this forum.

    Thanks

    Alan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •