+ Reply to Thread
Results 1 to 21 of 21

Application.screenupdating causing program lagg

  1. #1
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Application.screenupdating causing program lagg

    Hi,
    I made a program in Private Sub Worksheet_SelectionChange(ByVal Target As Range) event, so it will run some code everytime i select a cell.

    The problem is, I get a lagg (ie, the excel sheet "flashes") everytime i click on a cell.
    I am 100% sure the problem is caused by application.screenupdating, since if I remove that line, I don;t lagg; I get instant response
    Please Login or Register  to view this content.
    Any help would be appciated
    Thanks
    Last edited by adds007; 08-20-2010 at 12:56 PM.

  2. #2
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Application.screenupdating causing program lagg

    What are you doing in the code you omitted?
    Entia non sunt multiplicanda sine necessitate

  3. #3
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: Application.screenupdating causing program lagg

    I have 2 main codes in the event.
    first one, I can;t disclose cuz of company confidentiality issues. However, the problems still persists after commenting out this part.

    Second one, adds checkmarks

    Please Login or Register  to view this content.
    The weird thing is, sometimes the problem disappears, and I see instant response.
    When the problem is there tho, it;s annoying

  4. #4
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Application.screenupdating causing program lagg

    Do you have code in the worksheet change event?

    Do you have code that does Select?

  5. #5
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: Application.screenupdating causing program lagg

    Yes, I do have worksheet change event (not sure how it would be affect, just because of cliking)

    In worksheet selectionchange event, i do have some select code, but it starts off by enableevents=false and end with enableevents=true

    I hope those are the answers you were looking for

  6. #6
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Application.screenupdating causing program lagg

    Selects and Activates defeat ScreenUpdating. I reckon the run-time figures if you put them there, you meant to.

    EDIT: I should add, they are almost never necessary.
    Last edited by shg; 08-19-2010 at 03:49 PM.

  7. #7
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: Application.screenupdating causing program lagg

    i am sorry
    I am not sure what you mean by run-time figues and how to do it

  8. #8
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Application.screenupdating causing program lagg

    Post the code where you do Select

  9. #9
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: Application.screenupdating causing program lagg

    Please Login or Register  to view this content.
    I am gonna go home soon, sorry if i don;t reply fast enough
    I will definetly reply tomorrow, if not today

  10. #10
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Application.screenupdating causing program lagg

    So delete all the rows that do Select.

  11. #11
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Application.screenupdating causing program lagg

    Why do you Select those Ranges? You don't use them.

    What is this supposed to do?
    Please Login or Register  to view this content.
    It should be something like
    Please Login or Register  to view this content.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  12. #12
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Application.screenupdating causing program lagg

    When you set screenupdating to true you force a refresh, so it's not really that surprising that you get the effect you describe.
    Remember what the dormouse said
    Feed your head

  13. #13
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: Application.screenupdating causing program lagg

    Sorry for late reply, back to work

    @Shg, i commented out all selects in my event, the problem still persists

    @royUK,
    I need that code if i want to add a checkmark to the selected cell, if it's valid
    I copied this code from this forum i think. It seems to do what I want.
    I am pretty sure that's not the problem tho

    @romperstomper, I removed the last line Application.ScreenUpdating = True, but the problem still persists

    Thank you all for speedy responses

  14. #14
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Application.screenupdating causing program lagg

    It will be set back to true when the sub exits anyway. The point is to only set it to false if you actually need to. Otherwise you are forcing a redraw for no reason.

  15. #15
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: Application.screenupdating causing program lagg

    I need have the screenupdating=false, otherwise it takes too long for checkmarks to appear for multiple selected cells

  16. #16
    Forum Guru romperstomper's Avatar
    Join Date
    11-04-2008
    Location
    A1
    MS-Off Ver
    Most
    Posts
    12,302

    Re: Application.screenupdating causing program lagg

    But you turn it off whether or not you do anything.

  17. #17
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Application.screenupdating causing program lagg

    I think you would get a better answer if you posted the complete code probably by attaching a workbook & saying what you want to do.

  18. #18
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: Application.screenupdating causing program lagg

    ok so i did what you told me, and only added the line where i needed it
    Please Login or Register  to view this content.
    The good thing is, it doesn;t flash anymore for any columns except the checkmark column (column B)
    The bad thing is, it still flashes for like 0.5s when i place a checkmark or select multiple rows in column B

  19. #19
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: Application.screenupdating causing program lagg

    This is probably very bad example, but I can;t post the original cuz of confidentiality issues
    So i built a test workbook, which doesn;t really lagg (i don;t know why)
    I hope this is helpful
    Attached Files Attached Files

  20. #20
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Application.screenupdating causing program lagg

    Is this what you want
    Please Login or Register  to view this content.

  21. #21
    Forum Contributor
    Join Date
    06-14-2010
    Location
    Toronto,Canada
    MS-Off Ver
    Excel 2003
    Posts
    145

    Re: Application.screenupdating causing program lagg

    wow, that actually removed the flashes
    YOU ARE AMAZING!!!!
    just 1 small thing, if you don;t mind
    i can;t deselect a range of cells (checkmarks don;t disappear when i select multiple cells)
    I really appreciate it tho

    I am not sure why making this change caused the flashes to go away, I am really happy now tho
    Thanks again
    Last edited by adds007; 08-20-2010 at 12:57 PM.

+ 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